Tests are refactored
This commit is contained in:
@ -9,6 +9,7 @@ use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class InvoicesTest extends FeatureTestCase
|
||||
@ -181,16 +182,16 @@ class InvoicesTest extends FeatureTestCase
|
||||
$count = 5;
|
||||
Document::factory()->invoice()->count($count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('invoices.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
'/' . \Str::filename(trans_choice('general.invoices', 2)) . '-\d{10}\.xlsx/',
|
||||
Excel::assertDownloaded(
|
||||
'/' . str()->filename(trans_choice('general.invoices', 2), '-') . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->sheets()[0]->collection()->count() === $count;
|
||||
@ -205,7 +206,7 @@ class InvoicesTest extends FeatureTestCase
|
||||
|
||||
$invoices = Document::factory()->invoice()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
@ -214,10 +215,10 @@ class InvoicesTest extends FeatureTestCase
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
'/' . \Str::filename(trans_choice('general.invoices', 2)) . '-\d{10}\.xlsx/',
|
||||
Excel::assertDownloaded(
|
||||
'/' . str()->filename(trans_choice('general.invoices', 2), '-') . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->sheets()[0]->collection()->count() === $select_count;
|
||||
}
|
||||
@ -226,7 +227,7 @@ class InvoicesTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldImportInvoices()
|
||||
{
|
||||
\Excel::fake();
|
||||
Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
@ -240,7 +241,7 @@ class InvoicesTest extends FeatureTestCase
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::assertImported('invoices.xlsx');
|
||||
Excel::assertImported('invoices.xlsx');
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
Reference in New Issue
Block a user