fixed tests and bulk action export

This commit is contained in:
Denis Duliçi
2021-05-23 17:13:13 +03:00
parent 21e14f1191
commit 4e924ab46d
21 changed files with 274 additions and 149 deletions

View File

@ -131,8 +131,10 @@ class CustomersTest extends FeatureTestCase
->get(route('customers.export'))
->assertStatus(200);
\Excel::matchByRegex();
\Excel::assertDownloaded(
\Str::filename(trans_choice('general.customers', 2)) . '.xlsx',
'/' . \Str::filename(trans_choice('general.customers', 2)) . '-\d{10}\.xlsx/',
function (Export $export) use ($count) {
// Assert that the correct export is downloaded.
return $export->collection()->count() === $count;
@ -142,22 +144,26 @@ class CustomersTest extends FeatureTestCase
public function testItShouldExportSelectedCustomers()
{
$count = 5;
$customers = Contact::factory()->customer()->count($count)->create();
$create_count = 5;
$select_count = 3;
$customers = Contact::factory()->customer()->count($create_count)->create();
\Excel::fake();
$this->loginAs()
->post(
route('bulk-actions.action', ['group' => 'sales', 'type' => 'customers']),
['handle' => 'export', 'selected' => [$customers->random()->id]]
['handle' => 'export', 'selected' => $customers->take($select_count)->pluck('id')->toArray()]
)
->assertStatus(200);
\Excel::matchByRegex();
\Excel::assertDownloaded(
\Str::filename(trans_choice('general.customers', 2)) . '.xlsx',
function (Export $export) {
return $export->collection()->count() === 1;
'/' . \Str::filename(trans_choice('general.customers', 2)) . '-\d{10}\.xlsx/',
function (Export $export) use ($select_count) {
return $export->collection()->count() === $select_count;
}
);
}