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

@ -129,33 +129,39 @@ class InvoicesTest extends FeatureTestCase
->get(route('invoices.export'))
->assertStatus(200);
\Excel::matchByRegex();
\Excel::assertDownloaded(
\Str::filename(trans_choice('general.invoices', 2)) . '.xlsx',
'/' . \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()['invoices']->collection()->count() === $count;
return $export->sheets()[0]->collection()->count() === $count;
}
);
}
public function testItShouldExportSelectedInvoices()
{
$count = 5;
$invoices = Document::factory()->invoice()->count($count)->create();
$create_count = 5;
$select_count = 3;
$invoices = Document::factory()->invoice()->count($create_count)->create();
\Excel::fake();
$this->loginAs()
->post(
route('bulk-actions.action', ['group' => 'sales', 'type' => 'invoices']),
['handle' => 'export', 'selected' => [$invoices->random()->id]]
['handle' => 'export', 'selected' => $invoices->take($select_count)->pluck('id')->toArray()]
)
->assertStatus(200);
\Excel::matchByRegex();
\Excel::assertDownloaded(
\Str::filename(trans_choice('general.invoices', 2)) . '.xlsx',
function (Export $export) {
return $export->sheets()['invoices']->collection()->count() === 1;
'/' . \Str::filename(trans_choice('general.invoices', 2)) . '-\d{10}\.xlsx/',
function (Export $export) use ($select_count) {
return $export->sheets()[0]->collection()->count() === $select_count;
}
);
}