akaunting 3.0 (the last dance)
This commit is contained in:
@@ -99,7 +99,7 @@ class CustomersTest extends FeatureTestCase
|
||||
|
||||
$customer = $this->dispatch(new CreateContact($request));
|
||||
|
||||
$request['email'] = $this->faker->safeEmail;
|
||||
$request['email'] = $this->faker->freeEmail;
|
||||
|
||||
$this->loginAs()
|
||||
->patch(route('customers.update', $customer->id), $request)
|
||||
|
||||
@@ -83,10 +83,12 @@ class InvoicesTest extends FeatureTestCase
|
||||
$this->assertDatabaseHas('documents', [
|
||||
'document_number' => $request['document_number']
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('mediables', [
|
||||
'mediable_type' => Document::class,
|
||||
'tag' => 'attachment',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('media', [
|
||||
'disk' => 'uploads',
|
||||
'directory' => '2021/05/15/1/invoices',
|
||||
@@ -113,12 +115,13 @@ class InvoicesTest extends FeatureTestCase
|
||||
$request = $this->getRequest(true);
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('invoices.store'), $request)
|
||||
->post(route('recurring-invoices.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('documents', [
|
||||
'type' => Document::INVOICE_RECURRING_TYPE,
|
||||
'document_number' => $request['document_number'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Sales;
|
||||
|
||||
use App\Exports\Sales\Revenues as Export;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Models\Banking\Transaction;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class RevenuesTest extends FeatureTestCase
|
||||
{
|
||||
public function testItShouldSeeRevenueListPage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('revenues.index'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans_choice('general.revenues', 2));
|
||||
}
|
||||
|
||||
public function testItShouldSeeRevenueShowPage()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$revenue = $this->dispatch(new CreateTransaction($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('revenues.show', $revenue->id))
|
||||
->assertStatus(200)
|
||||
->assertSee($revenue->contact->email);
|
||||
}
|
||||
|
||||
public function testItShouldSeeRevenueCreatePage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('revenues.create'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.revenues', 1)]));
|
||||
}
|
||||
|
||||
public function testItShouldCreateRevenue()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('revenues.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('transactions', $request);
|
||||
}
|
||||
|
||||
public function testItShouldSeeRevenueUpdatePage()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$revenue = $this->dispatch(new CreateTransaction($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('revenues.edit', $revenue->id))
|
||||
->assertStatus(200)
|
||||
->assertSee($revenue->amount);
|
||||
}
|
||||
|
||||
public function testItShouldUpdateRevenue()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$revenue = $this->dispatch(new CreateTransaction($request));
|
||||
|
||||
$request['amount'] = $this->faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$this->loginAs()
|
||||
->patch(route('revenues.update', $revenue->id), $request)
|
||||
->assertStatus(200)
|
||||
->assertSee($request['amount']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('transactions', $request);
|
||||
}
|
||||
|
||||
public function testItShouldDeleteRevenue()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$revenue = $this->dispatch(new CreateTransaction($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('revenues.destroy', $revenue->id))
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertSoftDeleted('transactions', $request);
|
||||
}
|
||||
|
||||
public function testItShouldExportRevenues()
|
||||
{
|
||||
$count = 5;
|
||||
Transaction::factory()->income()->count($count)->create();
|
||||
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('revenues.export'))
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
'/' . \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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShouldExportSelectedRevenues()
|
||||
{
|
||||
$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->take($select_count)->pluck('id')->toArray()]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::matchByRegex();
|
||||
|
||||
\Excel::assertDownloaded(
|
||||
'/' . \Str::filename(trans_choice('general.revenues', 2)) . '-\d{10}\.xlsx/',
|
||||
function (Export $export) use ($select_count) {
|
||||
return $export->collection()->count() === $select_count;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShouldImportRevenues()
|
||||
{
|
||||
\Excel::fake();
|
||||
|
||||
$this->loginAs()
|
||||
->post(
|
||||
route('revenues.import'),
|
||||
[
|
||||
'import' => UploadedFile::fake()->createWithContent(
|
||||
'revenues.xlsx',
|
||||
File::get(public_path('files/import/revenues.xlsx'))
|
||||
),
|
||||
]
|
||||
)
|
||||
->assertStatus(200);
|
||||
|
||||
\Excel::assertImported('revenues.xlsx');
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
{
|
||||
return Transaction::factory()->income()->raw();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user