From 64ce53ac304b306f686f988d06087d60b4d6f2a8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 25 Jan 2015 10:55:15 +0100 Subject: [PATCH] Test for opening balance. --- .../TransactionJournal/TransactionJournal.php | 3 ++- tests/functional/AccountControllerCest.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php index 65b842871d..b3f6f5fd5c 100644 --- a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php +++ b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php @@ -382,7 +382,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C } } break; - + case (isset($model['from']) && isset($model['to'])): + break; default: throw new FireflyException('Cannot validate accounts for transaction journal.'); break; diff --git a/tests/functional/AccountControllerCest.php b/tests/functional/AccountControllerCest.php index 35ea055806..8848523ed6 100644 --- a/tests/functional/AccountControllerCest.php +++ b/tests/functional/AccountControllerCest.php @@ -114,6 +114,21 @@ class AccountControllerCest $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 */