From cac30f0b4c05b1b4848bc609d99c9b22ef806d6c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 25 Jan 2015 15:29:09 +0100 Subject: [PATCH] Updated code coverage. --- app/lib/FireflyIII/FF3ServiceProvider.php | 1 + app/lib/FireflyIII/Form/Form.php | 6 --- tests/functional/PiggyBankControllerCest.php | 24 +++++++++ .../RepeatedExpenseControllerCest.php | 54 +++++++++++++++++++ .../functional/TransactionControllerCest.php | 49 ++++++++++++++++- 5 files changed, 127 insertions(+), 7 deletions(-) diff --git a/app/lib/FireflyIII/FF3ServiceProvider.php b/app/lib/FireflyIII/FF3ServiceProvider.php index 879313a2d2..5940441dda 100644 --- a/app/lib/FireflyIII/FF3ServiceProvider.php +++ b/app/lib/FireflyIII/FF3ServiceProvider.php @@ -32,6 +32,7 @@ class FF3ServiceProvider extends ServiceProvider /** * Return the services bla bla. * + * @CodeCoverageIgnore * @return array */ public function provides() diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php index 5d4bb91574..dba4e144a8 100644 --- a/app/lib/FireflyIII/Form/Form.php +++ b/app/lib/FireflyIII/Form/Form.php @@ -88,9 +88,6 @@ class Form /** @var MessageBag $errors */ $errors = \Session::get('errors'); - /** @var MessageBag $warnings */ - $warnings = \Session::get('warnings'); - /** @var MessageBag $successes */ $successes = \Session::get('successes'); @@ -98,9 +95,6 @@ class Form case (!is_null($errors) && $errors->has($name)): $classes = 'form-group has-error has-feedback'; break; - case (!is_null($warnings) && $warnings->has($name)): - $classes = 'form-group has-warning has-feedback'; - break; case (!is_null($successes) && $successes->has($name)): $classes = 'form-group has-success has-feedback'; break; diff --git a/tests/functional/PiggyBankControllerCest.php b/tests/functional/PiggyBankControllerCest.php index fc00a93005..c0651993e8 100644 --- a/tests/functional/PiggyBankControllerCest.php +++ b/tests/functional/PiggyBankControllerCest.php @@ -193,6 +193,30 @@ class PiggyBankControllerCest 'account_id' => 1, 'targetamount' => 1000] ); $I->see('Piggy bank "Some new piggy bank" stored.'); + $I->seeRecord('piggy_banks', ['name' => 'Some new piggy bank']); + } + + /** + * @param FunctionalTester $I + */ + public function storeValidate(FunctionalTester $I) + { + $I->wantTo('validate a new piggy bank'); + $I->amOnPage('/piggy_banks/create'); + $I->see('Create new piggy bank'); + $I->submitForm( + '#store', ['name' => 'Some new piggy bank validated', + 'rep_every' => 0, + 'reminder_skip' => 0, + 'remind_me' => 0, + 'order' => 3, + 'post_submit_action' => 'validate_only', + 'account_id' => 1, + 'targetamount' => 1000] + ); + $I->see('OK'); + $I->seeInSession('successes'); + $I->dontSeeRecord('piggy_banks', ['name' => 'Some new piggy bank validated']); } /** diff --git a/tests/functional/RepeatedExpenseControllerCest.php b/tests/functional/RepeatedExpenseControllerCest.php index 58d2392ee2..b93ff8263b 100644 --- a/tests/functional/RepeatedExpenseControllerCest.php +++ b/tests/functional/RepeatedExpenseControllerCest.php @@ -117,6 +117,33 @@ class RepeatedExpenseControllerCest $I->see('Piggy bank "TestRepeatedExpense" stored.'); } + /** + * @param FunctionalTester $I + */ + public function storeValidate(FunctionalTester $I) + { + $I->wantTo('validate a repeated expense'); + $I->amOnPage('/repeatedexpenses/create'); + $I->submitForm( + '#store', [ + 'name' => 'TestRepeatedExpenseXX', + 'account_id' => 1, + 'targetamount' => 1000, + 'targetdate' => Carbon::now()->format('Y-m-d'), + 'rep_length' => 'month', + 'rep_every' => 0, + 'rep_times' => 0, + 'remind_me' => 1, + 'reminder' => 'month', + 'post_submit_action' => 'validate_only', + ] + ); + + $I->see('TestRepeatedExpenseXX'); + $I->see('OK'); + $I->seeInSession('successes'); + } + /** * @param FunctionalTester $I */ @@ -192,6 +219,33 @@ class RepeatedExpenseControllerCest $I->see('Repeated expense "' . $repeatedExpense->name . '!" updated.'); } + /** + * @param FunctionalTester $I + */ + public function updateValidate(FunctionalTester $I) + { + $repeatedExpense = PiggyBank::where('repeats', 1)->first(); + $I->wantTo('validate an updated repeated expense'); + $I->amOnPage('/repeatedexpenses/edit/' . $repeatedExpense->id); + $I->submitForm( + '#update', [ + 'name' => $repeatedExpense->name . 'ABCD', + 'account_id' => 2, + 'targetamount' => 1000.00, + 'targetdate' => $repeatedExpense->targetdate->format('Y-m-d'), + 'rep_length' => 'month', + 'rep_every' => 0, + 'rep_times' => 0, + 'remind_me' => 1, + 'reminder' => 'month', + 'post_submit_action' => 'validate_only', + ] + ); + $I->see($repeatedExpense->name . 'ABCD'); + $I->see('OK'); + $I->seeInSession('successes'); + } + /** * @param FunctionalTester $I */ diff --git a/tests/functional/TransactionControllerCest.php b/tests/functional/TransactionControllerCest.php index fa7caccfd5..6bd5444ad7 100644 --- a/tests/functional/TransactionControllerCest.php +++ b/tests/functional/TransactionControllerCest.php @@ -114,7 +114,7 @@ class TransactionControllerCest $I->wantTo('see a grouped transaction'); $I->amOnPage('/transaction/show/' . $journal->id); $I->see($journal->description); - $I->see('Money for '.$journal->description); + $I->see('Money for ' . $journal->description); } public function store(FunctionalTester $I) @@ -137,6 +137,29 @@ class TransactionControllerCest $I->see('Transaction "Test" stored.'); } + + public function storeValidate(FunctionalTester $I) + { + $I->wantTo('validate a transaction'); + $I->amOnPage('/transactions/create/withdrawal'); + $I->submitForm( + '#store', [ + 'reminder' => '', + 'description' => 'TestValidateMe', + 'account_id' => 1, + 'expense_account' => 'Zomaar', + 'amount' => 100, + 'date' => '2014-12-30', + 'budget_id' => 3, + 'category' => 'CategorrXXXXr', + 'post_submit_action' => 'validate_only' + ] + ); + $I->see('OK'); + $I->seeInSession('successes'); + $I->dontSeeRecord('transaction_journals', ['description' => 'TestValidateMe']); + } + public function storeAndFail(FunctionalTester $I) { $I->wantTo('store a transaction and fail'); @@ -199,6 +222,30 @@ class TransactionControllerCest $I->see($journal->description . '!'); } + public function updateValidate(FunctionalTester $I) + { + $journal = TransactionJournal::where('description', 'LIKE', '%Salary for %')->first(); + + $I->wantTo('validate an updated transaction'); + $I->amOnPage('/transaction/edit/' . $journal->id); + $I->see($journal->description); + $I->submitForm( + '#update', [ + 'description' => $journal->description . 'XYZ', + 'account_id' => 1, + 'expense_account' => 'Portaal', + 'amount' => 500, + 'date' => $journal->date->format('Y-m-d'), + 'budget_id' => is_null($journal->budgets()->first()) ? 0 : $journal->budgets()->first()->id, + 'category' => is_null($journal->categories()->first()) ? '' : $journal->categories()->first()->id, + 'post_submit_action' => 'validate_only' + ] + ); + $I->see($journal->description . 'XYZ'); + $I->see('OK'); + $I->seeInSession('successes'); + } + public function updateAndFail(FunctionalTester $I) { $journal = TransactionJournal::where('description', 'LIKE', '%Salary for %')->first();