added export/ bulk action export and import feature test for payments..
This commit is contained in:
parent
fff6029af3
commit
d7bd69eb5f
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Purchases;
|
namespace Tests\Feature\Purchases;
|
||||||
|
|
||||||
|
use App\Exports\Purchases\Payments as Export;
|
||||||
use App\Jobs\Banking\CreateTransaction;
|
use App\Jobs\Banking\CreateTransaction;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Models\Banking\Transaction;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class PaymentsTest extends FeatureTestCase
|
class PaymentsTest extends FeatureTestCase
|
||||||
@ -82,6 +85,69 @@ class PaymentsTest extends FeatureTestCase
|
|||||||
$this->assertSoftDeleted('transactions', $request);
|
$this->assertSoftDeleted('transactions', $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItShouldExportPayments()
|
||||||
|
{
|
||||||
|
$count = 5;
|
||||||
|
Transaction::factory()->expense()->count($count)->create();
|
||||||
|
|
||||||
|
\Excel::fake();
|
||||||
|
|
||||||
|
$this->loginAs()
|
||||||
|
->get(route('payments.export'))
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
\Excel::assertDownloaded(
|
||||||
|
\Str::filename(trans_choice('general.payments', 2)) . '.xlsx',
|
||||||
|
function (Export $export) use ($count) {
|
||||||
|
// Assert that the correct export is downloaded.
|
||||||
|
return $export->collection()->count() === $count;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldExportSelectedPayments()
|
||||||
|
{
|
||||||
|
$count = 5;
|
||||||
|
$payments = Transaction::factory()->expense()->count($count)->create();
|
||||||
|
|
||||||
|
\Excel::fake();
|
||||||
|
|
||||||
|
$this->loginAs()
|
||||||
|
->post(
|
||||||
|
route('bulk-actions.action', ['group' => 'purchases', 'type' => 'payments']),
|
||||||
|
['handle' => 'export', 'selected' => [$payments->random()->id]]
|
||||||
|
)
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
\Excel::assertDownloaded(
|
||||||
|
\Str::filename(trans_choice('general.payments', 2)) . '.xlsx',
|
||||||
|
function (Export $export) {
|
||||||
|
return $export->collection()->count() === 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldImportPayments()
|
||||||
|
{
|
||||||
|
\Excel::fake();
|
||||||
|
|
||||||
|
$this->loginAs()
|
||||||
|
->post(
|
||||||
|
route('payments.import'),
|
||||||
|
[
|
||||||
|
'import' => UploadedFile::fake()->createWithContent(
|
||||||
|
'payments.xlsx',
|
||||||
|
File::get(public_path('files/import/payments.xlsx'))
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
\Excel::assertImported('payments.xlsx');
|
||||||
|
|
||||||
|
$this->assertFlashLevel('success');
|
||||||
|
}
|
||||||
|
|
||||||
public function getRequest()
|
public function getRequest()
|
||||||
{
|
{
|
||||||
return Transaction::factory()->expense()->raw();
|
return Transaction::factory()->expense()->raw();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user