added export/ bulk action export and import feature test for invoices..
This commit is contained in:
parent
1d5ce19c03
commit
b626c76360
@ -155,7 +155,7 @@ class CustomersTest extends FeatureTestCase
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'purchases', 'type' => 'customers']),
|
||||
route('bulk-actions.action', ['group' => 'sales', 'type' => 'customers']),
|
||||
['handle' => 'export', 'selected' => [$customers->random()->id]]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
namespace Tests\Feature\Sales;
|
||||
|
||||
use App\Exports\Sales\Invoices as Export;
|
||||
use App\Jobs\Document\CreateDocument;
|
||||
use App\Models\Document\Document;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class InvoicesTest extends FeatureTestCase
|
||||
@ -115,6 +118,69 @@ class InvoicesTest extends FeatureTestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function testItShouldExportInvoices()
|
||||
{
|
||||
$count = 5;
|
||||
Document::factory()->invoice()->count($count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('invoices.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.invoices', 2)) . '.xlsx',
|
||||
function (Export $export) use ($count) {
|
||||
// Assert that the correct export is downloaded.
|
||||
return $export->sheets()['invoices']->collection()->count() === $count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShouldExportSelectedInvoices()
|
||||
{
|
||||
$count = 5;
|
||||
$invoices = Document::factory()->invoice()->count($count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('bulk-actions.action', ['group' => 'sales', 'type' => 'invoices']),
|
||||
['handle' => 'export', 'selected' => [$invoices->random()->id]]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
\Str::filename(trans_choice('general.invoices', 2)) . '.xlsx',
|
||||
function (Export $export) {
|
||||
return $export->sheets()['invoices']->collection()->count() === 1;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShouldImportInvoices()
|
||||
{
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('invoices.import'),
|
||||
[
|
||||
'import' => UploadedFile::fake()->createWithContent(
|
||||
'invoices.xlsx',
|
||||
File::get(public_path('files/import/invoices.xlsx'))
|
||||
),
|
||||
]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::assertImported('invoices.xlsx');
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function getRequest($recurring = false)
|
||||
{
|
||||
$factory = Document::factory();
|
||||
|
Loading…
x
Reference in New Issue
Block a user