Merge branch '1.3-dev' of github.com:akaunting/akaunting into 1.3-dev
This commit is contained in:
commit
582250a68d
90
tests/Feature/Banking/AccountsTest.php
Normal file
90
tests/Feature/Banking/AccountsTest.php
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
|
use App\Models\Banking\Account;
|
||||||
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
|
class AccountsTest extends FeatureTestCase
|
||||||
|
{
|
||||||
|
public function testItShouldSeeAccountListPage()
|
||||||
|
{
|
||||||
|
$this->loginAs()
|
||||||
|
->get(route('accounts.index'))
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertSeeText(trans_choice('general.accounts', 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldSeeAccountCreatePage()
|
||||||
|
{
|
||||||
|
$this->loginAs()
|
||||||
|
->get(route('accounts.create'))
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.accounts', 1)]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldCreateAccount()
|
||||||
|
{
|
||||||
|
$this->loginAs()
|
||||||
|
->post(url('banking/accounts'), $this->getAccountRequest())
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(url('banking/accounts'));
|
||||||
|
|
||||||
|
$this->assertFlashLevel('success');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldSeeAccountUpdatePage()
|
||||||
|
{
|
||||||
|
$account = Account::create($this->getAccountRequest());
|
||||||
|
|
||||||
|
$this->loginAs()
|
||||||
|
->get(route('accounts.edit', ['account' => $account->id]))
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertSee($account->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldUpdateAccount()
|
||||||
|
{
|
||||||
|
$request = $this->getAccountRequest();
|
||||||
|
|
||||||
|
$account= Account::create($request);
|
||||||
|
|
||||||
|
$request['name'] = $this->faker->text(5);
|
||||||
|
|
||||||
|
$this->loginAs()
|
||||||
|
->patch(url('banking/accounts', $account->id), $request)
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(url('banking/accounts'));
|
||||||
|
|
||||||
|
$this->assertFlashLevel('success');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItShouldDeleteAccount()
|
||||||
|
{
|
||||||
|
$account = Account::create($this->getAccountRequest());
|
||||||
|
|
||||||
|
$this->loginAs()
|
||||||
|
->delete(route('accounts.destroy', ['account' => $account]))
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('accounts.index'));
|
||||||
|
|
||||||
|
$this->assertFlashLevel('success');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getAccountRequest()
|
||||||
|
{
|
||||||
|
return[
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'name' => $this->faker->text(5),
|
||||||
|
'number' => '1',
|
||||||
|
'currency_code' => setting('general.default_currency'),
|
||||||
|
'opening_balance' => 0,
|
||||||
|
'bank_name' => $this->faker->text(5),
|
||||||
|
'bank_phone' => null,
|
||||||
|
'bank_address' => null,
|
||||||
|
'default_account' => $this->faker->randomElement(['yes', 'no']),
|
||||||
|
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user