Updated the test to be more dynamic.

This commit is contained in:
James Cole
2015-02-14 17:31:51 +01:00
parent 9af0fb4cd5
commit 74e319855d

View File

@@ -1,4 +1,5 @@
<?php <?php
use FireflyIII\Models\Account;
/** /**
* @SuppressWarnings("CamelCase") * @SuppressWarnings("CamelCase")
@@ -114,21 +115,6 @@ class AccountControllerCest
$I->seeRecord('accounts', ['name' => 'New through tests.']); $I->seeRecord('accounts', ['name' => 'New through tests.']);
} }
/**
* @param FunctionalTester $I
*/
public function storeOpeningBalance(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account with a balance');
$I->see('Create a new asset account');
$I->submitForm('#store', ['name' => 'New through tests with balance.',
'openingBalance' => 10,
'openingBalanceDate' => '2015-01-01',
'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'store']);
$I->seeRecord('accounts', ['name' => 'New through tests with balance.']);
}
/** /**
* @param FunctionalTester $I * @param FunctionalTester $I
*/ */
@@ -155,14 +141,33 @@ class AccountControllerCest
$I->dontSeeRecord('accounts', ['name' => 'New through tests.']); $I->dontSeeRecord('accounts', ['name' => 'New through tests.']);
} }
/**
* @param FunctionalTester $I
*/
public function storeOpeningBalance(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account with a balance');
$I->see('Create a new asset account');
$I->submitForm(
'#store', ['name' => 'New through tests with balance.',
'openingBalance' => 10,
'openingBalanceDate' => '2015-01-01',
'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'store']
);
$I->seeRecord('accounts', ['name' => 'New through tests with balance.']);
}
/** /**
* @param FunctionalTester $I * @param FunctionalTester $I
*/ */
public function update(FunctionalTester $I) public function update(FunctionalTester $I)
{ {
$account = Account::where('name', 'Delete me')->first();
$I->wantTo('update an asset account'); $I->wantTo('update an asset account');
$I->amOnPage('/accounts/edit/3'); $I->amOnPage('/accounts/edit/' . $account->id);
$I->see('Edit asset account &quot;Delete me&quot;'); $I->see('Edit asset account');
$I->see($account->name);
$I->submitForm('#update', ['name' => 'Update me', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']); $I->submitForm('#update', ['name' => 'Update me', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
$I->seeRecord('accounts', ['name' => 'Update me']); $I->seeRecord('accounts', ['name' => 'Update me']);
@@ -173,9 +178,11 @@ class AccountControllerCest
*/ */
public function updateAndReturn(FunctionalTester $I) public function updateAndReturn(FunctionalTester $I)
{ {
$account = Account::where('name', 'Savings account')->first();
$I->wantTo('update an asset account and return to form'); $I->wantTo('update an asset account and return to form');
$I->amOnPage('/accounts/edit/2'); $I->amOnPage('/accounts/edit/' . $account->id);
$I->see('Edit asset account &quot;Savings account&quot;'); $I->see('Edit asset account');
$I->see($account->name);
$I->submitForm( $I->submitForm(
'#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'return_to_edit'] '#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'return_to_edit']
); );