Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Updated some tests.
James Cole9e050fb059b3
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.phpindex 88d69cc294..bb77e99b52 100644--- a/app/Helpers/Report/ReportHelper.php+++ b/app/Helpers/Report/ReportHelper.php@@ -70,7 +70,7 @@ class ReportHelper implements ReportHelperInterfaceif ($account->accountType->type != 'Cash account') {return $account;}- }+ } // @codeCoverageIgnore);// summarize:diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex f043c0c568..ffdf6f4afc 100644--- a/app/Http/Controllers/HomeController.php+++ b/app/Http/Controllers/HomeController.php@@ -6,6 +6,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use Input;use Preferences;use Redirect;+use Route;use Session;use Steam;@@ -87,5 +88,78 @@ class HomeController extends Controllerreturn view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));}+ /**+ * @codeCoverageIgnore+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ */+ public function routes()+ {+ $directory = '/vagrant_data/Sites/firefly-iii-help';+ $languages = array_keys(Config::get('firefly.lang'));+ $routes = [];+ $ignored = [+ 'debugbar.openhandler', 'debugbar.assets.css', 'debugbar.assets.js', 'register', 'routes', 'daterange',+ 'flush', 'delete-account-post', 'change-password-post', 'logout', 'login', 'tags.hideTagHelp',+ 'budgets.postIncome', 'flush'+ ];++ $ignoreMatch = ['.store', '.update', '.destroy', 'json.'];++ $routeCollection = Route::getRoutes();+ /** @var \Illuminate\Routing\Route $object */+ foreach ($routeCollection as $object) {+ // get name:+ $name = $object->getName();+ // has name and not in ignore list?+ if (strlen($name) > 0 && !in_array($name, $ignored)) {++ // not in ignoreMatch?+ $continue = true;+ foreach ($ignoreMatch as $ignore) {+ $match = strpos($name, $ignore);+ if (!($match === false)) {+ $continue = false;+ }+ }+ unset($ignore, $match);++ if ($continue) {++ $routes[] = $name;++ // check all languages:+ foreach ($languages as $lang) {+ $file = $directory . '/' . $lang . '/' . $name . '.md';+ if (!file_exists($file)) {+ touch($file);+ echo $name . '<br />';+ }+ }+ }+++ }++ }++ // loop directories with language file.+ // tag the ones not in the list of approved routes.+ foreach ($languages as $lang) {+ $dir = $directory . '/' . $lang;+ $set = scandir($dir);+ foreach ($set as $entry) {+ if ($entry != '.' && $entry != '..') {+ $name = str_replace('.md', '', $entry);+ if (!in_array($name, $routes)) {+ $file = $dir . '/' . $entry;+ unlink($file);+ }+ }+ }+ }+ echo 'Done!';+ }+}diff --git a/app/Http/routes.php b/app/Http/routes.phpindex 9cff899bab..a5960cfce0 100644--- a/app/Http/routes.php+++ b/app/Http/routes.php@@ -193,6 +193,7 @@ Route::controllers(]);+Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);/*** Home Controllerdiff --git a/app/Models/Account.php b/app/Models/Account.phpindex 78e24f9ba6..5406c0616d 100644--- a/app/Models/Account.php+++ b/app/Models/Account.php@@ -18,6 +18,7 @@ class Account extends Modeluse SoftDeletes, ValidatingTrait;protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance'];+ protected $hidden = ['virtual_balance_encrypted', 'encrypted'];protected $rules= ['user_id' => 'required|exists:users,id',@@ -116,6 +117,7 @@ class Account extends Model/**** @param $fieldName+ * @codeCoverageIgnore** @return string|null*/@@ -151,7 +153,7 @@ class Account extends Model/*** @param $value- *+ * @codeCoverageIgnore* @return float|int*/public function getVirtualBalanceAttribute($value)@@ -220,6 +222,7 @@ class Account extends Model/*** @param $value+ * @codeCoverageIgnore*/public function setVirtualBalanceAttribute($value){diff --git a/app/Models/Bill.php b/app/Models/Bill.phpindex 2725ad9888..6fdac81b3d 100644--- a/app/Models/Bill.php+++ b/app/Models/Bill.php@@ -4,6 +4,7 @@ use Crypt;use Illuminate\Database\Eloquent\Model;/**+ * @codeCoverageIgnore* Class Bill** @package FireflyIII\Models@@ -14,6 +15,8 @@ class Bill extends Modelprotected $fillable= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];+ protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];+/*** @param $value*@@ -31,6 +34,7 @@ class Bill extends Model}/**+ ** @param $value** @return float|int@@ -66,9 +70,7 @@ class Bill extends Modelreturn Crypt::decrypt($value);}- // @codeCoverageIgnoreStartreturn $value;- // @codeCoverageIgnoreEnd}/**@@ -83,9 +85,7 @@ class Bill extends Modelreturn Crypt::decrypt($value);}- // @codeCoverageIgnoreStartreturn $value;- // @codeCoverageIgnoreEnd}/**diff --git a/app/Models/Budget.php b/app/Models/Budget.phpindex 7272639eac..64ee6d9f7a 100644--- a/app/Models/Budget.php+++ b/app/Models/Budget.php@@ -15,7 +15,8 @@ class Budget extends Modeluse SoftDeletes;- protected $fillable = ['user_id', 'name'];+ protected $fillable = ['user_id', 'name', 'active'];+ protected $hidden = ['encrypted'];/***@@ -46,9 +47,7 @@ class Budget extends Modelreturn Crypt::decrypt($value);}- // @codeCoverageIgnoreStartreturn $value;- // @codeCoverageIgnoreEnd}/**diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.phpindex 739330aa06..80cc4bcc71 100644--- a/app/Models/BudgetLimit.php+++ b/app/Models/BudgetLimit.php@@ -12,6 +12,8 @@ use Illuminate\Database\Eloquent\Model;class BudgetLimit extends Model{+ protected $hidden = ['amount_encrypted'];+/*** @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/diff --git a/app/Models/Category.php b/app/Models/Category.phpindex a37dae2fff..9a8245452e 100644--- a/app/Models/Category.php+++ b/app/Models/Category.php@@ -16,24 +16,7 @@ class Category extends Modeluse SoftDeletes;protected $fillable = ['user_id', 'name'];-- /**- * @codeCoverageIgnore- * @return array- */- public function getDates()- {- return ['created_at', 'updated_at', 'deleted_at'];- }-- /**- * @codeCoverageIgnore- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany- */- public function transactionjournals()- {- return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');- }+ protected $hidden = ['encrypted'];/*** @param array $fields@@ -71,39 +54,57 @@ class Category extends Model/*** @codeCoverageIgnore- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo+ * @return array*/- public function user()+ public function getDates(){- return $this->belongsTo('FireflyIII\User');+ return ['created_at', 'updated_at', 'deleted_at'];}/*** @codeCoverageIgnore** @param $value+ *+ * @return string*/- public function setNameAttribute($value)+ public function getNameAttribute($value){- $this->attributes['name'] = Crypt::encrypt($value);- $this->attributes['encrypted'] = true;++ if (intval($this->encrypted) == 1) {+ return Crypt::decrypt($value);+ }++ return $value;}/*** @codeCoverageIgnore** @param $value- *- * @return string*/- public function getNameAttribute($value)+ public function setNameAttribute($value){+ $this->attributes['name'] = Crypt::encrypt($value);+ $this->attributes['encrypted'] = true;+ }- if (intval($this->encrypted) == 1) {- return Crypt::decrypt($value);- }+ /**+ * @codeCoverageIgnore+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ */+ public function transactionjournals()+ {+ return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');+ }- return $value;+ /**+ * @codeCoverageIgnore+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo+ */+ public function user()+ {+ return $this->belongsTo('FireflyIII\User');}}diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.phpindex d0eca39e37..666c14d603 100644--- a/app/Models/LimitRepetition.php+++ b/app/Models/LimitRepetition.php@@ -1,20 +1,21 @@<?php namespace FireflyIII\Models;-use Auth;use Crypt;-use DB;use Illuminate\Database\Eloquent\Model;/*** Class LimitRepetition*+ * @codeCoverageIgnore+ ** @package FireflyIII\Models*/class LimitRepetition extends Model{+ protected $hidden = ['amount_encrypted'];+/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/public function budgetLimit()@@ -22,15 +23,6 @@ class LimitRepetition extends Modelreturn $this->belongsTo('FireflyIII\Models\BudgetLimit');}- /**- * @codeCoverageIgnore- * @return array- */- public function getDates()- {- return ['created_at', 'updated_at', 'startdate', 'enddate'];- }-/*** @param $value*@@ -47,6 +39,14 @@ class LimitRepetition extends Modelreturn $value;}+ /**+ * @return array+ */+ public function getDates()+ {+ return ['created_at', 'updated_at', 'startdate', 'enddate'];+ }+/*** @param $value*/diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.phpindex 2d7279ad1d..e3ce7e2b1b 100644--- a/app/Models/PiggyBank.php+++ b/app/Models/PiggyBank.php@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;/*** Class PiggyBank*+ * @codeCoverageIgnore+ ** @package FireflyIII\Models*/class PiggyBank extends Model@@ -14,10 +16,10 @@ class PiggyBank extends Modeluse SoftDeletes;protected $fillable- = ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];+ = ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];+ protected $hidden = ['targetamount_encrypted', 'encrypted'];/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/public function account()@@ -45,7 +47,6 @@ class PiggyBank extends Model}/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\HasMany*/public function piggyBankRepetitions()@@ -54,7 +55,6 @@ class PiggyBank extends Model}/**- * @codeCoverageIgnore* @return array*/public function getDates()@@ -63,7 +63,6 @@ class PiggyBank extends Model}/**- * @codeCoverageIgnore** @param $value*@@ -76,13 +75,10 @@ class PiggyBank extends Modelreturn Crypt::decrypt($value);}- // @codeCoverageIgnoreStartreturn $value;- // @codeCoverageIgnoreEnd}/**- * @codeCoverageIgnore** @param $value*@@ -110,7 +106,6 @@ class PiggyBank extends Model}/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\HasMany*/public function piggyBankEvents()@@ -119,7 +114,6 @@ class PiggyBank extends Model}/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\MorphMany*/public function reminders()@@ -128,7 +122,6 @@ class PiggyBank extends Model}/**- * @codeCoverageIgnore** @param $value*/diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.phpindex ad9ab0bb52..6e5ba604e5 100644--- a/app/Models/PiggyBankEvent.php+++ b/app/Models/PiggyBankEvent.php@@ -7,12 +7,14 @@ use Illuminate\Database\Eloquent\Model;* Class PiggyBankEvent** @codeCoverageIgnore+ ** @package FireflyIII\Models*/class PiggyBankEvent extends Model{protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];+ protected $hidden = ['amount_encrypted'];/*** @param $valuediff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.phpindex 1421f9219f..7d5893fb63 100644--- a/app/Models/PiggyBankRepetition.php+++ b/app/Models/PiggyBankRepetition.php@@ -15,6 +15,7 @@ class PiggyBankRepetition extends Model{protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];+ protected $hidden = ['currentamount_encrypted'];/*** @return arraydiff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex cb91740bcf..f09327bde3 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -13,6 +13,7 @@ class Preference extends Model{protected $fillable = ['user_id', 'data', 'name'];+ protected $hidden = ['data_encrypted', 'name_encrypted'];/*** @param $valuediff --git a/app/Models/Reminder.php b/app/Models/Reminder.phpindex 38da24deed..ddde2a7ed5 100644--- a/app/Models/Reminder.php+++ b/app/Models/Reminder.php@@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Model;/*** Class Reminder*+ * @codeCoverageIgnore+ ** @package FireflyIII\Models*/class Reminder extends Model@@ -15,9 +17,9 @@ class Reminder extends Modelprotected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',];+ protected $hidden = ['encrypted'];/**- * @codeCoverageIgnore** @param $value*@@ -29,7 +31,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore* @return array*/public function getDates()@@ -38,7 +39,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore** @param $value*@@ -54,7 +54,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore** @param $value*@@ -66,7 +65,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\MorphTo*/public function remindersable()@@ -75,7 +73,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore** @param EloquentBuilder $query* @param Carbon $start@@ -89,7 +86,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore** @param EloquentBuilder $query*@@ -104,7 +100,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore** @param $value*/@@ -115,7 +110,6 @@ class Reminder extends Model}/**- * @codeCoverageIgnore* @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/public function user()diff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex dea16ca928..8ff5b1cd6c 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -17,6 +17,7 @@ class Transaction extends Model{protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount'];+ protected $hidden = ['encrypted'];protected $rules= ['account_id' => 'required|exists:accounts,id',diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.phpindex 50870a4b6e..09b3d5d86d 100644--- a/app/Models/TransactionJournal.php+++ b/app/Models/TransactionJournal.php@@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\HasMany;use Illuminate\Database\Eloquent\SoftDeletes;-use Illuminate\Database\Query\JoinClause;use Watson\Validating\ValidatingTrait;/**@@ -19,9 +18,9 @@ class TransactionJournal extends Modeluse SoftDeletes, ValidatingTrait;protected $fillable = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted'];-+ protected $hidden = ['encrypted'];protected $rules- = [+ = ['user_id' => 'required|exists:users,id','transaction_type_id' => 'required|exists:transaction_types,id','bill_id' => 'exists:bills,id',diff --git a/tests/controllers/CategoryControllerTest.php b/tests/controllers/CategoryControllerTest.phpindex fafc60eee5..9c508ae767 100644--- a/tests/controllers/CategoryControllerTest.php+++ b/tests/controllers/CategoryControllerTest.php@@ -145,6 +145,7 @@ class CategoryControllerTest extends TestCase}+public function testStore(){// creatediff --git a/tests/controllers/TransactionControllerTest.php b/tests/controllers/TransactionControllerTest.phpindex c2d3924963..ad1f3033e0 100644--- a/tests/controllers/TransactionControllerTest.php+++ b/tests/controllers/TransactionControllerTest.php@@ -231,6 +231,8 @@ class TransactionControllerTest extends TestCase/*** @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @covers FireflyIII\Models\Category::firstOrCreateEncrypted+ * @covers FireflyIII\Models\Tag::firstOrCreateEncrypted*/public function testStore(){@@ -254,7 +256,7 @@ class TransactionControllerTest extends TestCase'budget_id' => '0','create_another' => '1','category' => '',- 'tags' => '',+ 'tags' => 'fat-test','piggy_bank_id' => '0','_token' => 'replaceMe',];@@ -277,6 +279,8 @@ class TransactionControllerTest extends TestCase/*** @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @covers FireflyIII\Models\Category::firstOrCreateEncrypted+ * @covers FireflyIII\Models\Tag::firstOrCreateEncrypted*/public function testStoreTransfer(){@@ -314,7 +318,7 @@ class TransactionControllerTest extends TestCase'budget_id' => '0','create_another' => '1','category' => '',- 'tags' => '',+ 'tags' => 'fat-test','piggy_bank_id' => $piggy->id,'_token' => 'replaceMe',];@@ -337,6 +341,8 @@ class TransactionControllerTest extends TestCase/*** @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @covers FireflyIII\Models\Category::firstOrCreateEncrypted+ * @covers FireflyIII\Models\Tag::firstOrCreateEncrypted*/public function testUpdate(){@@ -362,7 +368,7 @@ class TransactionControllerTest extends TestCase'date' => '2015-05-31','budget_id' => '0','category' => 'Lunch',- 'tags' => '',+ 'tags' => 'fat-test','piggy_bank_id' => '0',];@@ -385,6 +391,8 @@ class TransactionControllerTest extends TestCase/*** @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @covers FireflyIII\Models\Category::firstOrCreateEncrypted+ * @covers FireflyIII\Models\Tag::firstOrCreateEncrypted*/public function testUpdateWithRedirect(){@@ -411,7 +419,7 @@ class TransactionControllerTest extends TestCase'budget_id' => '0','category' => 'Lunch','return_to_edit' => 1,- 'tags' => '',+ 'tags' => 'fat-test','piggy_bank_id' => '0',];diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.phpindex 0e3fd323dc..fc470d2228 100644--- a/tests/repositories/AccountRepositoryTest.php+++ b/tests/repositories/AccountRepositoryTest.php@@ -611,6 +611,7 @@ class AccountRepositoryTest extends TestCase* @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount* @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata* @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance+ **/public function testStore(){@@ -686,6 +687,7 @@ class AccountRepositoryTest extends TestCase* @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount* @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata* @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance+ * @covers FireflyII\Models\Account::firstOrNullEncrypted* @expectedException Symfony\Component\HttpKernel\Exception\HttpException*/public function testStoreWithInvalidAccountData()