-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Batuhan Baş
committed
Nov 6, 2018
1 parent
e8fccd5
commit 5f50e81
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
]; | ||
} | ||
} | ||
|