fixed tests and bulk action export
This commit is contained in:
@ -84,8 +84,10 @@ class TransfersTest extends FeatureTestCase
|
||||
->get(route('transfers.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.transfers', 2)) . '.xlsx',
|
||||
'/' . \Str::filename(trans_choice('general.transfers', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->collection()->count() === $count;
|
||||
@ -95,22 +97,26 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldExportSelectedTransfers()
|
||||
{
|
||||
$count = 5;
|
||||
$transfers = Transfer::factory()->count($count)->create();
|
||||
$create_count = 5;
|
||||
$select_count = 3;
|
||||
|
||||
$transfers = Transfer::factory()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'banking', 'type' => 'transfers']),
|
||||
['handle' => 'export', 'selected' => [$transfers->random()->id]]
|
||||
['handle' => 'export', 'selected' => $transfers->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.transfers', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->collection()->count() === 1;
|
||||
'/' . \Str::filename(trans_choice('general.transfers', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->collection()->count() === $select_count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -96,33 +96,40 @@ class ItemsTest extends FeatureTestCase
|
||||
->get(route('items.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.items', 2)) . '.xlsx',
|
||||
'/' . \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()['items']->collection()->count() === $count;
|
||||
return $export->sheets()[0]->collection()->count() === $count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShouldExportSelectedItems()
|
||||
{
|
||||
$count = 5;
|
||||
$items = Item::factory()->count($count)->create();
|
||||
$create_count = 5;
|
||||
$select_count = 3;
|
||||
|
||||
$items = Item::factory()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'common', 'type' => 'items']),
|
||||
['handle' => 'export', 'selected' => [$items->random()->id]]
|
||||
['handle' => 'export', 'selected' => $items->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.items', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->sheets()['items']->collection()->count() === 1;
|
||||
'/' . \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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -118,33 +118,39 @@ class BillsTest extends FeatureTestCase
|
||||
->get(route('bills.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.bills', 2)) . '.xlsx',
|
||||
'/' . \Str::filename(trans_choice('general.bills', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->sheets()['bills']->collection()->count() === $count;
|
||||
return $export->sheets()[0]->collection()->count() === $count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShouldExportSelectedBills()
|
||||
{
|
||||
$count = 5;
|
||||
$bills = Document::factory()->bill()->count($count)->create();
|
||||
$create_count = 5;
|
||||
$select_count = 3;
|
||||
|
||||
$bills = Document::factory()->bill()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'purchases', 'type' => 'bills']),
|
||||
['handle' => 'export', 'selected' => [$bills->random()->id]]
|
||||
['handle' => 'export', 'selected' => $bills->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.bills', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->sheets()['bills']->collection()->count() === 1;
|
||||
'/' . \Str::filename(trans_choice('general.bills', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->sheets()[0]->collection()->count() === $select_count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -96,8 +96,10 @@ class PaymentsTest extends FeatureTestCase
|
||||
->get(route('payments.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.payments', 2)) . '.xlsx',
|
||||
'/' . \Str::filename(trans_choice('general.payments', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->collection()->count() === $count;
|
||||
@ -107,22 +109,26 @@ class PaymentsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldExportSelectedPayments()
|
||||
{
|
||||
$count = 5;
|
||||
$payments = Transaction::factory()->expense()->count($count)->create();
|
||||
$create_count = 5;
|
||||
$select_count = 3;
|
||||
|
||||
$payments = Transaction::factory()->expense()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'purchases', 'type' => 'payments']),
|
||||
['handle' => 'export', 'selected' => [$payments->random()->id]]
|
||||
['handle' => 'export', 'selected' => $payments->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.payments', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->collection()->count() === 1;
|
||||
'/' . \Str::filename(trans_choice('general.payments', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->collection()->count() === $select_count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -110,8 +110,10 @@ class VendorsTest extends FeatureTestCase
|
||||
->get(route('vendors.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.vendors', 2)) . '.xlsx',
|
||||
'/' . \Str::filename(trans_choice('general.vendors', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->collection()->count() === $count;
|
||||
@ -121,22 +123,26 @@ class VendorsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldExportSelectedVendors()
|
||||
{
|
||||
$count = 5;
|
||||
$vendors = Contact::factory()->vendor()->count($count)->create();
|
||||
$create_count = 5;
|
||||
$select_count = 3;
|
||||
|
||||
$vendors = Contact::factory()->vendor()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'purchases', 'type' => 'vendors']),
|
||||
['handle' => 'export', 'selected' => [$vendors->random()->id]]
|
||||
['handle' => 'export', 'selected' => $vendors->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.vendors', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->collection()->count() === 1;
|
||||
'/' . \Str::filename(trans_choice('general.vendors', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->collection()->count() === $select_count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -96,8 +96,10 @@ class RevenuesTest extends FeatureTestCase
|
||||
->get(route('revenues.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.revenues', 2)) . '.xlsx',
|
||||
'/' . \Str::filename(trans_choice('general.revenues', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->collection()->count() === $count;
|
||||
@ -107,22 +109,26 @@ class RevenuesTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldExportSelectedRevenues()
|
||||
{
|
||||
$count = 5;
|
||||
$revenues = Transaction::factory()->income()->count($count)->create();
|
||||
$create_count = 5;
|
||||
$select_count = 3;
|
||||
|
||||
$revenues = Transaction::factory()->income()->count($create_count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'sales', 'type' => 'revenues']),
|
||||
['handle' => 'export', 'selected' => [$revenues->random()->id]]
|
||||
['handle' => 'export', 'selected' => $revenues->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.revenues', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->collection()->count() === 1;
|
||||
'/' . \Str::filename(trans_choice('general.revenues', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->collection()->count() === $select_count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user