Tests are refactored
This commit is contained in:
@ -7,6 +7,7 @@ use App\Jobs\Common\CreateItem;
|
||||
use App\Models\Common\Item;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class ItemsTest extends FeatureTestCase
|
||||
@ -90,16 +91,16 @@ class ItemsTest extends FeatureTestCase
|
||||
$count = 5;
|
||||
Item::factory()->count($count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('items.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
'/' . \Str::filename(trans_choice('general.items', 2)) . '-\d{10}\.xlsx/',
|
||||
Excel::assertDownloaded(
|
||||
'/' . str()->filename(trans_choice('general.items', 2), '-') . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->sheets()[0]->collection()->count() === $count;
|
||||
@ -114,7 +115,7 @@ class ItemsTest extends FeatureTestCase
|
||||
|
||||
$items = Item::factory()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
@ -123,10 +124,10 @@ class ItemsTest extends FeatureTestCase
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
'/' . \Str::filename(trans_choice('general.items', 2)) . '-\d{10}\.xlsx/',
|
||||
Excel::assertDownloaded(
|
||||
'/' . str()->filename(trans_choice('general.items', 2), '-') . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->sheets()[0]->collection()->count() === $select_count;
|
||||
@ -136,7 +137,7 @@ class ItemsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldImportItems()
|
||||
{
|
||||
\Excel::fake();
|
||||
Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
@ -150,7 +151,7 @@ class ItemsTest extends FeatureTestCase
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::assertImported('items.xlsx');
|
||||
Excel::assertImported('items.xlsx');
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
Reference in New Issue
Block a user