Skip to content

Firefly III: a personal finances manager

Some refactoring.

James Cole8c3ae40de10b
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 .= '<div class="input-group"><div class="input-group-addon">'.getCurrencySymbol().'</div>';
+ $html .= '<div class="input-group"><div class="input-group-addon">' . getCurrencySymbol() . '</div>';
$html .= \Form::input('number', $name, $value, $options);
$html .= '</div>';
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
@@ -96,13 +96,13 @@ class ReportHelper implements ReportHelperInterface
}
/**
- * Sort an array where all 'amount' keys are negative floats.
+ * Sort an array where all 'amount' keys are positive floats.
*
* @param array $array
*
* @return array
*/
- public function sortNegativeArray(array $array)
+ public function sortArray(array $array)
{
uasort(
$array, function ($left, $right) {
@@ -110,31 +110,33 @@ class ReportHelper implements ReportHelperInterface
return 0;
}
- return ($left['amount'] < $right['amount']) ? -1 : 1;
+ return ($left['amount'] < $right['amount']) ? 1 : -1;
}
);
return $array;
+
}
/**
- * Sort an array where all 'amount' keys are positive floats.
+ * Sort an array where all 'amount' keys are negative floats.
*
* @param array $array
*
* @return array
*/
- public function sortArray(array $array) {
+ public function sortNegativeArray(array $array)
+ {
uasort(
$array, function ($left, $right) {
if ($left['amount'] == $right['amount']) {
return 0;
}
- return ($left['amount'] < $right['amount']) ? 1 : -1;
+ return ($left['amount'] < $right['amount']) ? -1 : 1;
}
);
- return $array;
+ 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
@@ -44,21 +44,21 @@ interface ReportHelperInterface
public function mergeArrays(array $one, array $two);
/**
- * Sort an array where all 'amount' keys are negative floats.
+ * Sort an array where all 'amount' keys are positive floats.
*
* @param array $array
*
* @return array
*/
- public function sortNegativeArray(array $array);
+ public function sortArray(array $array);
/**
- * Sort an array where all 'amount' keys are positive floats.
+ * Sort an array where all 'amount' keys are negative floats.
*
* @param array $array
*
* @return array
*/
- public function sortArray(array $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 @@
<?php
namespace FireflyIII\Shared\Toolkit;
+
use Carbon\Carbon;
use FireflyIII\Exception\FireflyException;
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Steam.php b/app/lib/FireflyIII/Shared/Toolkit/Steam.php
index 275089449a..7daf2708e5 100644
--- a/app/lib/FireflyIII/Shared/Toolkit/Steam.php
+++ b/app/lib/FireflyIII/Shared/Toolkit/Steam.php
@@ -23,7 +23,7 @@ class Steam
*/
public function balance(\Account $account, Carbon $date = null)
{
- \Log::debug('Now in Steam::balance() for account #' . $account->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 @@
<i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})
</div>
<div class="panel-body">
- @include('...lists.old.journals-small-noaccount',['transactions' => $result['transactions']])
+ @include('list.journals-small',['journals' => $result['transactions']])
</div>
</div>
</div>
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
*/
@@ -149,58 +147,60 @@ class AccountControllerCest
/**
* @param FunctionalTester $I
*/
- public function update(FunctionalTester $I)
+ public function storeValidateOnly(FunctionalTester $I)
{
- $I->wantTo('update an asset account');
- $I->amOnPage('/accounts/edit/3');
- $I->see('Edit asset account "Delete me"');
- $I->submitForm('#update', ['name' => 'Update me', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
- $I->seeRecord('accounts', ['name' => 'Update me']);
+ $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
*/
- public function failUpdate(FunctionalTester $I)
+ public function update(FunctionalTester $I)
{
- $I->wantTo('update an asset account and fail');
+ $I->wantTo('update an asset account');
$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']);
+ $I->submitForm('#update', ['name' => 'Update me', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
+ $I->seeRecord('accounts', ['name' => 'Update me']);
+ resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
- public function validateUpdateOnly(FunctionalTester $I)
+ public function updateAndReturn(FunctionalTester $I)
{
- $I->wantTo('update an asset account and validate only');
+ $I->wantTo('update an asset account and return to form');
$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']
+ '#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'return_to_edit']
);
- $I->dontSeeRecord('accounts', ['name' => 'Savings accountXX']);
+ $I->seeRecord('accounts', ['name' => 'Savings accountXX']);
+ resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
- public function updateAndReturn(FunctionalTester $I)
+ public function validateUpdateOnly(FunctionalTester $I)
{
- $I->wantTo('update an asset account and return to form');
+ $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' => 'return_to_edit']
+ '#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']
);
- $I->seeRecord('accounts', ['name' => 'Savings accountXX']);
- resetToClean::clean();
+ $I->dontSeeRecord('accounts', ['name' => 'Savings accountXX']);
}
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
@@ -220,44 +220,44 @@ class BillControllerCest
/**
* @param FunctionalTester $I
*/
- public function updateReturn(FunctionalTester $I)
+ public function updateFail(FunctionalTester $I)
{
- $I->wantTo('update a bill and return to edit it');
+ $I->wantTo('update a bill and fail');
$I->amOnPage('/bills/edit/1');
$I->submitForm(
'#update', [
'name' => 'Some bill',
- 'match' => 'bla,bla',
+ 'match' => '',
'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 &quot;Some bill&quot; updated.');
+ $I->see('Could not update bill');
}
/**
* @param FunctionalTester $I
*/
- public function updateFail(FunctionalTester $I)
+ public function updateReturn(FunctionalTester $I)
{
- $I->wantTo('update a bill and fail');
+ $I->wantTo('update a bill and return to edit it');
$I->amOnPage('/bills/edit/1');
$I->submitForm(
'#update', [
- 'name' => 'Some bill',
- 'match' => '',
- 'amount_min' => 10,
- 'amount_max' => 20,
- 'date' => date('Y-m-d'),
- 'repeat_freq' => 'monthly',
- 'skip' => 0
+ '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('Could not update bill');
+ $I->see('Bill &quot;Some bill&quot; 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
*/
@@ -141,40 +154,39 @@ class BudgetControllerCest
/**
* @param FunctionalTester $I
*/
- public function storeValidateOnly(FunctionalTester $I)
+ public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
- $I->wantTo('validate a new budget');
+ $I->wantTo('store a new budget and create another');
$I->see('Create a new budget');
- $I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'validate_only']);
- $I->dontSeeRecord('budgets', ['name' => 'New budget.']);
+ $I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'create_another']);
+ $I->seeRecord('budgets', ['name' => 'New budget.']);
}
/**
* @param FunctionalTester $I
*/
- public function storeAndCreateAnother(FunctionalTester $I)
+ public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
- $I->wantTo('store a new budget and create another');
+ $I->wantTo('make storing a new budget fail.');
$I->see('Create a new budget');
- $I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'create_another']);
- $I->seeRecord('budgets', ['name' => 'New budget.']);
+ $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'store']);
+ $I->dontSeeRecord('budgets', ['name' => 'New budget.']);
}
/**
* @param FunctionalTester $I
*/
- public function storeFail(FunctionalTester $I)
+ public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
- $I->wantTo('make storing a new budget fail.');
+ $I->wantTo('validate a new budget');
$I->see('Create a new budget');
- $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'store']);
+ $I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('budgets', ['name' => 'New budget.']);
}
-
/**
* @param FunctionalTester $I
*/
@@ -192,54 +204,41 @@ 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 validateUpdateOnly(FunctionalTester $I)
+ public function updateIncome(FunctionalTester $I)
{
- $I->wantTo('update a budget and validate only');
- $I->amOnPage('/budgets/edit/3');
- $I->see('Edit budget "Delete me"');
- $I->submitForm(
- '#update', ['name' => 'Validate Only', 'post_submit_action' => 'validate_only']
- );
- $I->dontSeeRecord('budgets', ['name' => 'Savings accountXX']);
- $I->seeRecord('budgets', ['name' => 'Delete me']);
-
+ $I->amOnPage('/budgets/income');
+ $I->wantTo('update my monthly income');
+ $I->see('Update (expected) income for ');
}
/**
* @param FunctionalTester $I
*/
- public function updateAndReturn(FunctionalTester $I)
+ public function validateUpdateOnly(FunctionalTester $I)
{
- $I->wantTo('update a budget and return to form');
+ $I->wantTo('update a budget and validate only');
$I->amOnPage('/budgets/edit/3');
$I->see('Edit budget "Delete me"');
$I->submitForm(
- '#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit']
+ '#update', ['name' => 'Validate Only', 'post_submit_action' => 'validate_only']
);
- $I->seeRecord('budgets', ['name' => 'Savings accountXX']);
-
- }
+ $I->dontSeeRecord('budgets', ['name' => 'Savings accountXX']);
+ $I->seeRecord('budgets', ['name' => 'Delete me']);
- /**
- * @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
*/
@@ -100,41 +113,42 @@ class CategoryControllerCest
/**
* @param FunctionalTester $I
*/
- public function storeValidateOnly(FunctionalTester $I)
+ public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
- $I->wantTo('validate a new category');
+ $I->wantTo('store a new category and create another');
$I->see('Create a new category');
- $I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'validate_only']);
- $I->dontSeeRecord('categories', ['name' => 'New category.']);
+ $I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'create_another']);
+ $I->seeRecord('categories', ['name' => 'New category.']);
resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
- public function storeAndCreateAnother(FunctionalTester $I)
+ public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
- $I->wantTo('store a new category and create another');
+ $I->wantTo('make storing a new category fail.');
$I->see('Create a new category');
- $I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'create_another']);
- $I->seeRecord('categories', ['name' => 'New category.']);
+ $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'validate_only']);
+ $I->dontSeeRecord('categories', ['name' => 'New category.']);
resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
- public function storeFail(FunctionalTester $I)
+ public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
- $I->wantTo('make storing a new category fail.');
+ $I->wantTo('validate a new category');
$I->see('Create a new category');
- $I->submitForm('#store', ['name' => null, 'post_submit_action' => 'validate_only']);
+ $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 &quot;Hungarian forint&quot; 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 &quot;Some new piggy bank&quot; 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.');
}
@@ -286,46 +286,46 @@ class PiggyBankControllerCest
/**
* @param FunctionalTester $I
*/
- public function updateValidateOnly(FunctionalTester $I)
+ public function updateFail(FunctionalTester $I)
{
- $I->wantTo('validate a piggy bank');
+ $I->wantTo('update a piggy bank and fail');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
$I->submitForm(
'#update', [
- 'name' => 'Updated camera',
+ 'name' => '',
'account_id' => 2,
'targetamount' => 2000,
'targetdate' => '',
'reminder' => 'week',
- 'post_submit_action' => 'validate_only',
+ 'post_submit_action' => 'update',
]
);
- $I->see('Updated camera');
-
+ $I->see('The name field is required.');
+ $I->seeInDatabase('piggy_banks', ['name' => 'New camera']);
}
/**
* @param FunctionalTester $I
*/
- public function updateFail(FunctionalTester $I)
+ public function updateValidateOnly(FunctionalTester $I)
{
- $I->wantTo('update a piggy bank and fail');
+ $I->wantTo('validate a piggy bank');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
$I->submitForm(
'#update', [
- 'name' => '',
+ 'name' => 'Updated camera',
'account_id' => 2,
'targetamount' => 2000,
'targetdate' => '',
'reminder' => 'week',
- 'post_submit_action' => 'update',
+ 'post_submit_action' => 'validate_only',
]
);
- $I->see('The name field is required.');
- $I->seeInDatabase('piggy_banks', ['name' => 'New camera']);
+ $I->see('Updated camera');
+
}
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
@@ -88,9 +88,9 @@ class ProfileControllerCest
/**
* @param FunctionalTester $I
*/
- public function postChangePasswordNoNewPassword(FunctionalTester $I)
+ public function postChangePasswordNoMatch(FunctionalTester $I)
{
- $I->wantTo('submit a new password and forget to fill in a new one.');
+ $I->wantTo('submit a new password but make a mistake in filling it in twice.');
$I->amOnPage('/profile/change-password');
$I->see('[email protected]');
$I->see('Change your password');
@@ -98,20 +98,19 @@ class ProfileControllerCest
$I->submitForm(
'#change-password', [
'old' => 'james',
- 'new1' => '',
- 'new2' => ''
+ 'new1' => 'blabla',
+ 'new2' => 'bla'
]
);
- $I->see('Do fill in a password!');
-
+ $I->see('New passwords do not match!');
}
/**
* @param FunctionalTester $I
*/
- public function postChangePasswordToSame(FunctionalTester $I)
+ public function postChangePasswordNoNewPassword(FunctionalTester $I)
{
- $I->wantTo('submit a new password but fill in my old one twice.');
+ $I->wantTo('submit a new password and forget to fill in a new one.');
$I->amOnPage('/profile/change-password');
$I->see('[email protected]');
$I->see('Change your password');
@@ -119,19 +118,20 @@ class ProfileControllerCest
$I->submitForm(
'#change-password', [
'old' => 'james',
- 'new1' => 'james',
- 'new2' => 'james'
+ 'new1' => '',
+ 'new2' => ''
]
);
- $I->see('The idea is to change your password.');
+ $I->see('Do fill in a password!');
+
}
/**
* @param FunctionalTester $I
*/
- public function postChangePasswordNoMatch(FunctionalTester $I)
+ public function postChangePasswordToSame(FunctionalTester $I)
{
- $I->wantTo('submit a new password but make a mistake in filling it in twice.');
+ $I->wantTo('submit a new password but fill in my old one twice.');
$I->amOnPage('/profile/change-password');
$I->see('[email protected]');
$I->see('Change your password');
@@ -139,11 +139,11 @@ class ProfileControllerCest
$I->submitForm(
'#change-password', [
'old' => 'james',
- 'new1' => 'blabla',
- 'new2' => 'bla'
+ 'new1' => 'james',
+ 'new2' => 'james'
]
);
- $I->see('New passwords do not match!');
+ $I->see('The idea is to change your password.');
}
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 &quot;TestRepeatedExpense&quot; stored.');
}