diff --git a/app/lib/FireflyIII/Chart/Chart.php b/app/lib/FireflyIII/Chart/Chart.php index c390105efb..3b97eabbc3 100644 --- a/app/lib/FireflyIII/Chart/Chart.php +++ b/app/lib/FireflyIII/Chart/Chart.php @@ -58,18 +58,18 @@ class Chart implements ChartInterface ->where('transaction_journals.date', '<=', $end->format('Y-m-d')); } ) - ->leftJoin( - 'transactions', function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0); - } - ) - ->where('active', 1) - ->groupBy('bills.id') - ->get( - ['bills.id', 'bills.name', 'transaction_journals.description', - 'transaction_journals.id as journalId', - \DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'), - 'transactions.amount AS actualAmount'] - ); + ->leftJoin( + 'transactions', function (JoinClause $join) { + $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0); + } + ) + ->where('active', 1) + ->groupBy('bills.id') + ->get( + ['bills.id', 'bills.name', 'transaction_journals.description', + 'transaction_journals.id as journalId', + \DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'), + 'transactions.amount AS actualAmount'] + ); } } \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/Bill/Bill.php b/app/lib/FireflyIII/Database/Bill/Bill.php index bee5256214..6cb839c653 100644 --- a/app/lib/FireflyIII/Database/Bill/Bill.php +++ b/app/lib/FireflyIII/Database/Bill/Bill.php @@ -65,7 +65,7 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface /* * Jump to the start of the period. */ - $date = \DateKit::startOfPeriod($date, $data['repeat_freq']); + $date = \DateKit::startOfPeriod($date, $data['repeat_freq']); $bill->date = $date; $bill->skip = intval($data['skip']); @@ -193,9 +193,9 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface } /** - * @param \Bill $bill - * @param Carbon $start - * @param Carbon $end + * @param \Bill $bill + * @param Carbon $start + * @param Carbon $end * * @return \TransactionJournal|null */ @@ -206,8 +206,8 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface } /** - * @param \Bill $bill - * @param \TransactionJournal $journal + * @param \Bill $bill + * @param \TransactionJournal $journal * * @return bool */ diff --git a/app/lib/FireflyIII/Database/Budget/Budget.php b/app/lib/FireflyIII/Database/Budget/Budget.php index d6df9dbbfc..5dfe0d862d 100644 --- a/app/lib/FireflyIII/Database/Budget/Budget.php +++ b/app/lib/FireflyIII/Database/Budget/Budget.php @@ -238,6 +238,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface /** * This method includes the time because otherwise, SQLite doesn't understand it. + * * @param \Budget $budget * @param Carbon $date * @@ -369,6 +370,5 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface return $budget->budgetLimits()->where('startdate', $date->format('Y-m-d 00:00:00'))->first(); - } } \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/PiggyBank/PiggyBank.php b/app/lib/FireflyIII/Database/PiggyBank/PiggyBank.php index a6313626ca..bfcdaf66a5 100644 --- a/app/lib/FireflyIII/Database/PiggyBank/PiggyBank.php +++ b/app/lib/FireflyIII/Database/PiggyBank/PiggyBank.php @@ -6,7 +6,6 @@ use FireflyIII\Database\CommonDatabaseCalls; use FireflyIII\Database\CUD; use FireflyIII\Exception\FireflyException; use FireflyIII\Exception\NotImplementedException; -use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Support\Collection; /** diff --git a/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php b/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php index eb762b6395..fe012fb50c 100644 --- a/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php +++ b/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php @@ -2,7 +2,6 @@ namespace FireflyIII\Database\PiggyBank; -use Carbon\Carbon; use FireflyIII\Database\SwitchUser; use FireflyIII\Exception\NotImplementedException; use Illuminate\Database\Eloquent\Model as Eloquent; diff --git a/app/lib/FireflyIII/Database/PiggyBank/RepeatedExpense.php b/app/lib/FireflyIII/Database/PiggyBank/RepeatedExpense.php index f6edef18d2..2c11ff2d2f 100644 --- a/app/lib/FireflyIII/Database/PiggyBank/RepeatedExpense.php +++ b/app/lib/FireflyIII/Database/PiggyBank/RepeatedExpense.php @@ -6,9 +6,6 @@ namespace FireflyIII\Database\PiggyBank; use FireflyIII\Collection\PiggyBankPart; use FireflyIII\Database\CommonDatabaseCalls; use FireflyIII\Database\CUD; -use FireflyIII\Database\SwitchUser; -use FireflyIII\Exception\NotImplementedException; -use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Support\Collection; /** diff --git a/app/lib/FireflyIII/Event/TransactionJournal.php b/app/lib/FireflyIII/Event/TransactionJournal.php index ebb5e344f0..d58aba6bd0 100644 --- a/app/lib/FireflyIII/Event/TransactionJournal.php +++ b/app/lib/FireflyIII/Event/TransactionJournal.php @@ -44,8 +44,8 @@ class TransactionJournal public function update(\TransactionJournal $journal) { /** @var \FireflyIII\Database\Bill\Bill $repository */ - $repository = \App::make('FireflyIII\Database\Bill\Bill'); - $set = $repository->get(); + $repository = \App::make('FireflyIII\Database\Bill\Bill'); + $set = $repository->get(); $journal->bill_id = null; $journal->save(); diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php index 13bf163944..55e20004fa 100644 --- a/app/lib/FireflyIII/Form/Form.php +++ b/app/lib/FireflyIII/Form/Form.php @@ -123,7 +123,7 @@ class Form $html .= \Form::input('text', $name, $value, $options); break; case 'amount': - $html .= '
'.getCurrencySymbol().'
'; + $html .= '
' . getCurrencySymbol() . '
'; $html .= \Form::input('number', $name, $value, $options); $html .= '
'; break; diff --git a/app/lib/FireflyIII/Report/ReportHelper.php b/app/lib/FireflyIII/Report/ReportHelper.php index 6d82ae261a..354cf4c174 100644 --- a/app/lib/FireflyIII/Report/ReportHelper.php +++ b/app/lib/FireflyIII/Report/ReportHelper.php @@ -95,6 +95,29 @@ class ReportHelper implements ReportHelperInterface return $one; } + /** + * Sort an array where all 'amount' keys are positive floats. + * + * @param array $array + * + * @return array + */ + public function sortArray(array $array) + { + uasort( + $array, function ($left, $right) { + if ($left['amount'] == $right['amount']) { + return 0; + } + + return ($left['amount'] < $right['amount']) ? 1 : -1; + } + ); + + return $array; + + } + /** * Sort an array where all 'amount' keys are negative floats. * @@ -116,25 +139,4 @@ class ReportHelper implements ReportHelperInterface return $array; } - - /** - * Sort an array where all 'amount' keys are positive floats. - * - * @param array $array - * - * @return array - */ - public function sortArray(array $array) { - uasort( - $array, function ($left, $right) { - if ($left['amount'] == $right['amount']) { - return 0; - } - - return ($left['amount'] < $right['amount']) ? 1 : -1; - } - ); - return $array; - - } } \ No newline at end of file diff --git a/app/lib/FireflyIII/Report/ReportHelperInterface.php b/app/lib/FireflyIII/Report/ReportHelperInterface.php index 762af0bee6..111d1ac348 100644 --- a/app/lib/FireflyIII/Report/ReportHelperInterface.php +++ b/app/lib/FireflyIII/Report/ReportHelperInterface.php @@ -43,15 +43,6 @@ interface ReportHelperInterface */ public function mergeArrays(array $one, array $two); - /** - * Sort an array where all 'amount' keys are negative floats. - * - * @param array $array - * - * @return array - */ - public function sortNegativeArray(array $array); - /** * Sort an array where all 'amount' keys are positive floats. * @@ -61,4 +52,13 @@ interface ReportHelperInterface */ public function sortArray(array $array); + /** + * Sort an array where all 'amount' keys are negative floats. + * + * @param array $array + * + * @return array + */ + public function sortNegativeArray(array $array); + } \ No newline at end of file diff --git a/app/lib/FireflyIII/Report/ReportQuery.php b/app/lib/FireflyIII/Report/ReportQuery.php index 75728b597c..355568bd1a 100644 --- a/app/lib/FireflyIII/Report/ReportQuery.php +++ b/app/lib/FireflyIII/Report/ReportQuery.php @@ -44,8 +44,8 @@ class ReportQuery implements ReportQueryInterface * and are balanced by a transfer to make up for it. * * @param \Account $account - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return Collection */ @@ -97,8 +97,8 @@ class ReportQuery implements ReportQueryInterface * and are balanced by a transfer to make up for it. * * @param \Account $account - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return float */ diff --git a/app/lib/FireflyIII/Report/ReportQueryInterface.php b/app/lib/FireflyIII/Report/ReportQueryInterface.php index a33d6ee8ad..bed6501e71 100644 --- a/app/lib/FireflyIII/Report/ReportQueryInterface.php +++ b/app/lib/FireflyIII/Report/ReportQueryInterface.php @@ -47,8 +47,8 @@ interface ReportQueryInterface * and are balanced by a transfer to make up for it. * * @param \Account $account - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return float */ @@ -59,8 +59,8 @@ interface ReportQueryInterface * and are balanced by a transfer to make up for it. * * @param \Account $account - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return Collection */ diff --git a/app/lib/FireflyIII/Shared/Preferences/Preferences.php b/app/lib/FireflyIII/Shared/Preferences/Preferences.php index d7d335dcd7..40c4ec35f7 100644 --- a/app/lib/FireflyIII/Shared/Preferences/Preferences.php +++ b/app/lib/FireflyIII/Shared/Preferences/Preferences.php @@ -24,6 +24,7 @@ class Preferences implements PreferencesInterface if (!is_null($pref)) { return $pref; } + return $this->set($name, $default); } diff --git a/app/lib/FireflyIII/Shared/Toolkit/Navigation.php b/app/lib/FireflyIII/Shared/Toolkit/Navigation.php index 4800201f30..003735942f 100644 --- a/app/lib/FireflyIII/Shared/Toolkit/Navigation.php +++ b/app/lib/FireflyIII/Shared/Toolkit/Navigation.php @@ -1,6 +1,7 @@ id.' ('.$account->name.')'); + \Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')'); if (is_null($date)) { $key = 'account.' . $account->id . '.latestBalance'; } else { @@ -33,7 +33,7 @@ class Steam // TODO find a way to reliably remove cache entries for accounts. #return \Cache::get($key); } - $date = is_null($date) ? Carbon::now() : $date; + $date = is_null($date) ? Carbon::now() : $date; \Log::debug('Now reached the moment we fire the query.'); $balance = floatval( $account->transactions()->leftJoin( diff --git a/app/views/search/index.blade.php b/app/views/search/index.blade.php index d5f9e43e46..d1431ebe73 100644 --- a/app/views/search/index.blade.php +++ b/app/views/search/index.blade.php @@ -10,7 +10,7 @@ Transactions ({{$result['transactions']->count()}})
- @include('...lists.old.journals-small-noaccount',['transactions' => $result['transactions']]) + @include('list.journals-small',['journals' => $result['transactions']])
diff --git a/tests/functional/AccountControllerCest.php b/tests/functional/AccountControllerCest.php index 6f63f66031..103dd6c9b2 100644 --- a/tests/functional/AccountControllerCest.php +++ b/tests/functional/AccountControllerCest.php @@ -68,6 +68,19 @@ class AccountControllerCest $I->see('Edit asset account "Delete me"'); } + /** + * @param FunctionalTester $I + */ + public function failUpdate(FunctionalTester $I) + { + $I->wantTo('update an asset account and fail'); + $I->amOnPage('/accounts/edit/3'); + $I->see('Edit asset account "Delete me"'); + $I->submitForm('#update', ['name' => '', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']); + $I->seeRecord('accounts', ['name' => 'Delete me']); + + } + /** * @param FunctionalTester $I */ @@ -103,21 +116,6 @@ class AccountControllerCest resetToClean::clean(); } - /** - * @param FunctionalTester $I - */ - public function storeValidateOnly(FunctionalTester $I) - { - $I->amOnPage('/accounts/create/asset'); - $I->wantTo('validate a new asset account'); - $I->see('Create a new asset account'); - $I->submitForm( - '#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only'] - ); - $I->dontSeeRecord('accounts', ['name' => 'New through tests.']); - resetToClean::clean(); - } - /** * @param FunctionalTester $I */ @@ -146,6 +144,21 @@ class AccountControllerCest resetToClean::clean(); } + /** + * @param FunctionalTester $I + */ + public function storeValidateOnly(FunctionalTester $I) + { + $I->amOnPage('/accounts/create/asset'); + $I->wantTo('validate a new asset account'); + $I->see('Create a new asset account'); + $I->submitForm( + '#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only'] + ); + $I->dontSeeRecord('accounts', ['name' => 'New through tests.']); + resetToClean::clean(); + } + /** * @param FunctionalTester $I */ @@ -160,34 +173,6 @@ class AccountControllerCest } - /** - * @param FunctionalTester $I - */ - public function failUpdate(FunctionalTester $I) - { - $I->wantTo('update an asset account and fail'); - $I->amOnPage('/accounts/edit/3'); - $I->see('Edit asset account "Delete me"'); - $I->submitForm('#update', ['name' => '', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']); - $I->seeRecord('accounts', ['name' => 'Delete me']); - - } - - /** - * @param FunctionalTester $I - */ - public function validateUpdateOnly(FunctionalTester $I) - { - $I->wantTo('update an asset account and validate only'); - $I->amOnPage('/accounts/edit/2'); - $I->see('Edit asset account "Savings account"'); - $I->submitForm( - '#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only'] - ); - $I->dontSeeRecord('accounts', ['name' => 'Savings accountXX']); - - } - /** * @param FunctionalTester $I */ @@ -204,4 +189,19 @@ class AccountControllerCest } + /** + * @param FunctionalTester $I + */ + public function validateUpdateOnly(FunctionalTester $I) + { + $I->wantTo('update an asset account and validate only'); + $I->amOnPage('/accounts/edit/2'); + $I->see('Edit asset account "Savings account"'); + $I->submitForm( + '#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only'] + ); + $I->dontSeeRecord('accounts', ['name' => 'Savings accountXX']); + + } + } \ No newline at end of file diff --git a/tests/functional/BillControllerCest.php b/tests/functional/BillControllerCest.php index 188bc52f2e..1b93ca5f97 100644 --- a/tests/functional/BillControllerCest.php +++ b/tests/functional/BillControllerCest.php @@ -217,28 +217,6 @@ class BillControllerCest $I->see('Bill "Some bill" updated.'); } - /** - * @param FunctionalTester $I - */ - public function updateReturn(FunctionalTester $I) - { - $I->wantTo('update a bill and return to edit it'); - $I->amOnPage('/bills/edit/1'); - $I->submitForm( - '#update', [ - 'name' => 'Some bill', - 'match' => 'bla,bla', - 'amount_min' => 10, - 'amount_max' => 20, - 'post_submit_action' => 'return_to_edit', - 'date' => date('Y-m-d'), - 'repeat_freq' => 'monthly', - 'skip' => 0 - ] - ); - $I->see('Bill "Some bill" updated.'); - } - /** * @param FunctionalTester $I */ @@ -260,4 +238,26 @@ class BillControllerCest $I->see('Could not update bill'); } + /** + * @param FunctionalTester $I + */ + public function updateReturn(FunctionalTester $I) + { + $I->wantTo('update a bill and return to edit it'); + $I->amOnPage('/bills/edit/1'); + $I->submitForm( + '#update', [ + 'name' => 'Some bill', + 'match' => 'bla,bla', + 'amount_min' => 10, + 'amount_max' => 20, + 'post_submit_action' => 'return_to_edit', + 'date' => date('Y-m-d'), + 'repeat_freq' => 'monthly', + 'skip' => 0 + ] + ); + $I->see('Bill "Some bill" updated.'); + } + } \ No newline at end of file diff --git a/tests/functional/BudgetControllerCest.php b/tests/functional/BudgetControllerCest.php index 2789345917..3e9d2ec79e 100644 --- a/tests/functional/BudgetControllerCest.php +++ b/tests/functional/BudgetControllerCest.php @@ -82,6 +82,19 @@ class BudgetControllerCest $I->see('Edit budget "Delete me"'); } + /** + * @param FunctionalTester $I + */ + public function failUpdate(FunctionalTester $I) + { + $I->wantTo('update a budget and fail'); + $I->amOnPage('/budgets/edit/3'); + $I->see('Edit budget "Delete me"'); + $I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']); + $I->seeRecord('budgets', ['name' => 'Delete me']); + + } + /** * @param FunctionalTester $I */ @@ -138,18 +151,6 @@ class BudgetControllerCest resetToClean::clean(); } - /** - * @param FunctionalTester $I - */ - public function storeValidateOnly(FunctionalTester $I) - { - $I->amOnPage('/budgets/create'); - $I->wantTo('validate a new budget'); - $I->see('Create a new budget'); - $I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'validate_only']); - $I->dontSeeRecord('budgets', ['name' => 'New budget.']); - } - /** * @param FunctionalTester $I */ @@ -170,10 +171,21 @@ class BudgetControllerCest $I->amOnPage('/budgets/create'); $I->wantTo('make storing a new budget fail.'); $I->see('Create a new budget'); - $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'store']); + $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'store']); $I->dontSeeRecord('budgets', ['name' => 'New budget.']); } + /** + * @param FunctionalTester $I + */ + public function storeValidateOnly(FunctionalTester $I) + { + $I->amOnPage('/budgets/create'); + $I->wantTo('validate a new budget'); + $I->see('Create a new budget'); + $I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'validate_only']); + $I->dontSeeRecord('budgets', ['name' => 'New budget.']); + } /** * @param FunctionalTester $I @@ -192,16 +204,28 @@ class BudgetControllerCest /** * @param FunctionalTester $I */ - public function failUpdate(FunctionalTester $I) + public function updateAndReturn(FunctionalTester $I) { - $I->wantTo('update a budget and fail'); + $I->wantTo('update a budget and return to form'); $I->amOnPage('/budgets/edit/3'); $I->see('Edit budget "Delete me"'); - $I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']); - $I->seeRecord('budgets', ['name' => 'Delete me']); + $I->submitForm( + '#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit'] + ); + $I->seeRecord('budgets', ['name' => 'Savings accountXX']); } + /** + * @param FunctionalTester $I + */ + public function updateIncome(FunctionalTester $I) + { + $I->amOnPage('/budgets/income'); + $I->wantTo('update my monthly income'); + $I->see('Update (expected) income for '); + } + /** * @param FunctionalTester $I */ @@ -217,29 +241,4 @@ class BudgetControllerCest $I->seeRecord('budgets', ['name' => 'Delete me']); } - - /** - * @param FunctionalTester $I - */ - public function updateAndReturn(FunctionalTester $I) - { - $I->wantTo('update a budget and return to form'); - $I->amOnPage('/budgets/edit/3'); - $I->see('Edit budget "Delete me"'); - $I->submitForm( - '#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit'] - ); - $I->seeRecord('budgets', ['name' => 'Savings accountXX']); - - } - - /** - * @param FunctionalTester $I - */ - public function updateIncome(FunctionalTester $I) - { - $I->amOnPage('/budgets/income'); - $I->wantTo('update my monthly income'); - $I->see('Update (expected) income for '); - } } \ No newline at end of file diff --git a/tests/functional/CategoryControllerCest.php b/tests/functional/CategoryControllerCest.php index 85db3e03f3..8c688fcabb 100644 --- a/tests/functional/CategoryControllerCest.php +++ b/tests/functional/CategoryControllerCest.php @@ -65,6 +65,19 @@ class CategoryControllerCest $I->see('Edit category "Delete me"'); } + /** + * @param FunctionalTester $I + */ + public function failUpdate(FunctionalTester $I) + { + $I->wantTo('update a category and fail'); + $I->amOnPage('/categories/edit/4'); + $I->see('Edit category "Delete me"'); + $I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']); + $I->seeRecord('categories', ['name' => 'Delete me']); + + } + /** * @param FunctionalTester $I */ @@ -97,19 +110,6 @@ class CategoryControllerCest resetToClean::clean(); } - /** - * @param FunctionalTester $I - */ - public function storeValidateOnly(FunctionalTester $I) - { - $I->amOnPage('/categories/create'); - $I->wantTo('validate a new category'); - $I->see('Create a new category'); - $I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'validate_only']); - $I->dontSeeRecord('categories', ['name' => 'New category.']); - resetToClean::clean(); - } - /** * @param FunctionalTester $I */ @@ -131,10 +131,24 @@ class CategoryControllerCest $I->amOnPage('/categories/create'); $I->wantTo('make storing a new category fail.'); $I->see('Create a new category'); - $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'validate_only']); + $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'validate_only']); $I->dontSeeRecord('categories', ['name' => 'New category.']); resetToClean::clean(); } + + /** + * @param FunctionalTester $I + */ + public function storeValidateOnly(FunctionalTester $I) + { + $I->amOnPage('/categories/create'); + $I->wantTo('validate a new category'); + $I->see('Create a new category'); + $I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'validate_only']); + $I->dontSeeRecord('categories', ['name' => 'New category.']); + resetToClean::clean(); + } + /** * @param FunctionalTester $I */ @@ -152,13 +166,15 @@ class CategoryControllerCest /** * @param FunctionalTester $I */ - public function failUpdate(FunctionalTester $I) + public function updateAndReturn(FunctionalTester $I) { - $I->wantTo('update a category and fail'); + $I->wantTo('update a category and return to form'); $I->amOnPage('/categories/edit/4'); $I->see('Edit category "Delete me"'); - $I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']); - $I->seeRecord('categories', ['name' => 'Delete me']); + $I->submitForm( + '#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit'] + ); + $I->seeRecord('categories', ['name' => 'Savings accountXX']); } @@ -178,19 +194,4 @@ class CategoryControllerCest } - /** - * @param FunctionalTester $I - */ - public function updateAndReturn(FunctionalTester $I) - { - $I->wantTo('update a category and return to form'); - $I->amOnPage('/categories/edit/4'); - $I->see('Edit category "Delete me"'); - $I->submitForm( - '#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit'] - ); - $I->seeRecord('categories', ['name' => 'Savings accountXX']); - - } - } \ No newline at end of file diff --git a/tests/functional/CurrencyControllerCest.php b/tests/functional/CurrencyControllerCest.php index 47f4bf2ec2..a5e6726a59 100644 --- a/tests/functional/CurrencyControllerCest.php +++ b/tests/functional/CurrencyControllerCest.php @@ -35,6 +35,16 @@ class CurrencyControllerCest $I->see('Create a new currency'); } + /** + * @param FunctionalTester $I + */ + public function defaultCurrency(FunctionalTester $I) + { + $I->wantTo('make US Dollar the default currency'); + $I->amOnPage('/currency/default/2'); + $I->see('US Dollar is now the default currency.'); + } + /** * @param FunctionalTester $I */ @@ -57,16 +67,6 @@ class CurrencyControllerCest $I->see('Currency "Hungarian forint" deleted'); } - /** - * @param FunctionalTester $I - */ - public function defaultCurrency(FunctionalTester $I) - { - $I->wantTo('make US Dollar the default currency'); - $I->amOnPage('/currency/default/2'); - $I->see('US Dollar is now the default currency.'); - } - /** * @param FunctionalTester $I */ @@ -87,6 +87,19 @@ class CurrencyControllerCest $I->see('Edit currency "US Dollar"'); } + /** + * @param FunctionalTester $I + */ + public function failUpdate(FunctionalTester $I) + { + $I->wantTo('update a currency and fail'); + $I->amOnPage('/currency/edit/2'); + $I->see('Edit currency "US Dollar"'); + $I->submitForm('#update', ['name' => 'Failed update', 'code' => '123', 'post_submit_action' => 'update']); + $I->dontSeeRecord('transaction_currencies', ['name' => 'Failed update']); + + } + /** * @param FunctionalTester $I */ @@ -162,13 +175,15 @@ class CurrencyControllerCest /** * @param FunctionalTester $I */ - public function failUpdate(FunctionalTester $I) + public function updateAndReturn(FunctionalTester $I) { - $I->wantTo('update a currency and fail'); + $I->wantTo('update a currency and return to form'); $I->amOnPage('/currency/edit/2'); $I->see('Edit currency "US Dollar"'); - $I->submitForm('#update', ['name' => 'Failed update', 'code' => '123', 'post_submit_action' => 'update']); - $I->dontSeeRecord('transaction_currencies', ['name' => 'Failed update']); + $I->submitForm( + '#update', ['name' => 'US DollarXXX', 'symbol' => '$', 'code' => 'USD', 'post_submit_action' => 'return_to_edit'] + ); + $I->seeRecord('transaction_currencies', ['name' => 'US DollarXXX']); } @@ -185,19 +200,4 @@ class CurrencyControllerCest $I->seeRecord('transaction_currencies', ['name' => 'US Dollar']); } - - /** - * @param FunctionalTester $I - */ - public function updateAndReturn(FunctionalTester $I) - { - $I->wantTo('update a currency and return to form'); - $I->amOnPage('/currency/edit/2'); - $I->see('Edit currency "US Dollar"'); - $I->submitForm( - '#update', ['name' => 'US DollarXXX', 'symbol' => '$', 'code' => 'USD', 'post_submit_action' => 'return_to_edit'] - ); - $I->seeRecord('transaction_currencies', ['name' => 'US DollarXXX']); - - } } \ No newline at end of file diff --git a/tests/functional/GoogleChartControllerCest.php b/tests/functional/GoogleChartControllerCest.php index 3cab18f197..b0697dcc42 100644 --- a/tests/functional/GoogleChartControllerCest.php +++ b/tests/functional/GoogleChartControllerCest.php @@ -26,20 +26,20 @@ class GoogleChartControllerCest /** * @param FunctionalTester $I */ - public function accountBalanceChart(FunctionalTester $I) + public function accountAllBalanceChart(FunctionalTester $I) { - $I->wantTo('see the session balance chart of an account.'); - $I->amOnPage('chart/account/1/session'); + $I->wantTo('see the complete balance chart of an account.'); + $I->amOnPage('chart/account/1/all'); $I->seeResponseCodeIs(200); } /** * @param FunctionalTester $I */ - public function accountAllBalanceChart(FunctionalTester $I) + public function accountBalanceChart(FunctionalTester $I) { - $I->wantTo('see the complete balance chart of an account.'); - $I->amOnPage('chart/account/1/all'); + $I->wantTo('see the session balance chart of an account.'); + $I->amOnPage('chart/account/1/session'); $I->seeResponseCodeIs(200); } @@ -73,6 +73,26 @@ class GoogleChartControllerCest $I->seeResponseCodeIs(200); } + /** + * @param FunctionalTester $I + */ + public function billOverview(FunctionalTester $I) + { + $I->wantTo('see the chart for the history of a bill'); + $I->amOnPage('/chart/bills/1'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function billsOverview(FunctionalTester $I) + { + $I->wantTo('see the chart for which bills I have yet to pay'); + $I->amOnPage('/chart/home/bills'); + $I->seeResponseCodeIs(200); + } + /** * @param FunctionalTester $I */ @@ -125,26 +145,6 @@ class GoogleChartControllerCest $I->see('Invalid year'); } - /** - * @param FunctionalTester $I - */ - public function piggyBankHistory(FunctionalTester $I) - { - $I->wantTo('see the chart for the history of a piggy bank'); - $I->amOnPage('/chart/piggy_history/1'); - $I->seeResponseCodeIs(200); - } - - /** - * @param FunctionalTester $I - */ - public function billOverview(FunctionalTester $I) - { - $I->wantTo('see the chart for the history of a bill'); - $I->amOnPage('/chart/bills/1'); - $I->seeResponseCodeIs(200); - } - /** * @param FunctionalTester $I */ @@ -158,10 +158,10 @@ class GoogleChartControllerCest /** * @param FunctionalTester $I */ - public function billsOverview(FunctionalTester $I) + public function piggyBankHistory(FunctionalTester $I) { - $I->wantTo('see the chart for which bills I have yet to pay'); - $I->amOnPage('/chart/home/bills'); + $I->wantTo('see the chart for the history of a piggy bank'); + $I->amOnPage('/chart/piggy_history/1'); $I->seeResponseCodeIs(200); } diff --git a/tests/functional/PiggyBankControllerCest.php b/tests/functional/PiggyBankControllerCest.php index 00c2d906a0..0b717f639b 100644 --- a/tests/functional/PiggyBankControllerCest.php +++ b/tests/functional/PiggyBankControllerCest.php @@ -211,7 +211,7 @@ class PiggyBankControllerCest 'remind_me' => 0, 'order' => 3, 'account_id' => 1, - 'targetamount' => 1000] + 'targetamount' => 1000] ); $I->see('Piggy bank "Some new piggy bank" stored.'); } @@ -225,14 +225,14 @@ class PiggyBankControllerCest $I->amOnPage('/piggy_banks/create'); $I->see('Create new piggy bank'); $I->submitForm( - '#store', ['name' => null, - 'rep_every' => 0, - 'reminder_skip' => 0, - 'remind_me' => 0, - 'order' => 3, - 'account_id' => 1, + '#store', ['name' => null, + 'rep_every' => 0, + 'reminder_skip' => 0, + 'remind_me' => 0, + 'order' => 3, + 'account_id' => 1, 'post_submit_action' => 'store', - 'targetamount' => 1000] + 'targetamount' => 1000] ); $I->see('The name field is required.'); } @@ -281,29 +281,6 @@ class PiggyBankControllerCest $I->see('Piggy bank "Updated camera" updated.'); - } - - /** - * @param FunctionalTester $I - */ - public function updateValidateOnly(FunctionalTester $I) - { - $I->wantTo('validate a piggy bank'); - $I->amOnPage('/piggy_banks/edit/1'); - $I->see('Edit piggy bank "New camera"'); - $I->submitForm( - '#update', [ - 'name' => 'Updated camera', - 'account_id' => 2, - 'targetamount' => 2000, - 'targetdate' => '', - 'reminder' => 'week', - 'post_submit_action' => 'validate_only', - ] - ); - $I->see('Updated camera'); - - } /** @@ -329,4 +306,27 @@ class PiggyBankControllerCest } + /** + * @param FunctionalTester $I + */ + public function updateValidateOnly(FunctionalTester $I) + { + $I->wantTo('validate a piggy bank'); + $I->amOnPage('/piggy_banks/edit/1'); + $I->see('Edit piggy bank "New camera"'); + $I->submitForm( + '#update', [ + 'name' => 'Updated camera', + 'account_id' => 2, + 'targetamount' => 2000, + 'targetdate' => '', + 'reminder' => 'week', + 'post_submit_action' => 'validate_only', + ] + ); + $I->see('Updated camera'); + + + } + } \ No newline at end of file diff --git a/tests/functional/ProfileControllerCest.php b/tests/functional/ProfileControllerCest.php index 9a83e7ae5f..cb79784cbc 100644 --- a/tests/functional/ProfileControllerCest.php +++ b/tests/functional/ProfileControllerCest.php @@ -85,6 +85,26 @@ class ProfileControllerCest $I->see('Invalid current password!'); } + /** + * @param FunctionalTester $I + */ + public function postChangePasswordNoMatch(FunctionalTester $I) + { + $I->wantTo('submit a new password but make a mistake in filling it in twice.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + + $I->submitForm( + '#change-password', [ + 'old' => 'james', + 'new1' => 'blabla', + 'new2' => 'bla' + ] + ); + $I->see('New passwords do not match!'); + } + /** * @param FunctionalTester $I */ @@ -126,25 +146,5 @@ class ProfileControllerCest $I->see('The idea is to change your password.'); } - /** - * @param FunctionalTester $I - */ - public function postChangePasswordNoMatch(FunctionalTester $I) - { - $I->wantTo('submit a new password but make a mistake in filling it in twice.'); - $I->amOnPage('/profile/change-password'); - $I->see('thegrumpydictator@gmail.com'); - $I->see('Change your password'); - - $I->submitForm( - '#change-password', [ - 'old' => 'james', - 'new1' => 'blabla', - 'new2' => 'bla' - ] - ); - $I->see('New passwords do not match!'); - } - } \ No newline at end of file diff --git a/tests/functional/ReminderControllerCest.php b/tests/functional/ReminderControllerCest.php index fe5d0e738a..5677e44d07 100644 --- a/tests/functional/ReminderControllerCest.php +++ b/tests/functional/ReminderControllerCest.php @@ -34,6 +34,16 @@ class ReminderControllerCest $I->see('Money for Weekly reminder for clothes'); } + /** + * @param FunctionalTester $I + */ + public function actOnInvalid(FunctionalTester $I) + { + $I->wantTo('act on an invalid reminder'); + $I->amOnPage('/reminders/2/act'); + $I->see('This reminder has an invalid class connected to it.'); + } + /** * @param FunctionalTester $I */ @@ -65,14 +75,4 @@ class ReminderControllerCest $I->see('your piggy bank labelled "Weekly reminder for clothes"'); } - /** - * @param FunctionalTester $I - */ - public function actOnInvalid(FunctionalTester $I) - { - $I->wantTo('act on an invalid reminder'); - $I->amOnPage('/reminders/2/act'); - $I->see('This reminder has an invalid class connected to it.'); - } - } \ No newline at end of file diff --git a/tests/functional/RepeatedExpenseControllerCest.php b/tests/functional/RepeatedExpenseControllerCest.php index eb71aa5963..3432bec715 100644 --- a/tests/functional/RepeatedExpenseControllerCest.php +++ b/tests/functional/RepeatedExpenseControllerCest.php @@ -109,7 +109,6 @@ class RepeatedExpenseControllerCest ] ); -// $I->seeInDatabase('piggy_banks', ['name' => 'TestRepeatedExpense']); $I->see('Piggy bank "TestRepeatedExpense" stored.'); }