Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code cleanup.
James Cole0ef6d2f91aa5
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.phpindex af0a5a5b8e..68afc940c3 100644--- a/app/Providers/AppServiceProvider.php+++ b/app/Providers/AppServiceProvider.php@@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;* Class AppServiceProvider** @package FireflyIII\Providers+ *+ * @codeCoverageIgnore*/class AppServiceProvider extends ServiceProvider{diff --git a/app/Providers/BusServiceProvider.php b/app/Providers/BusServiceProvider.phpindex 0edb595695..dc2e86ac21 100644--- a/app/Providers/BusServiceProvider.php+++ b/app/Providers/BusServiceProvider.php@@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;/*** Class BusServiceProvider*+ * @codeCoverageIgnore+ ** @package FireflyIII\Providers*/class BusServiceProvider extends ServiceProviderdiff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.phpindex df8e7269d0..53d1e50b0b 100644--- a/app/Providers/ConfigServiceProvider.php+++ b/app/Providers/ConfigServiceProvider.php@@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;* Class ConfigServiceProvider** @package FireflyIII\Providers+ * @codeCoverageIgnore+ **/class ConfigServiceProvider extends ServiceProvider{diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.phpindex e3e1a90fb9..eff456ea08 100644--- a/app/Providers/FireflyServiceProvider.php+++ b/app/Providers/FireflyServiceProvider.php@@ -23,6 +23,7 @@ use Validator;* Class FireflyServiceProvider** @package FireflyIII\Providers+ * @codeCoverageIgnore*/class FireflyServiceProvider extends ServiceProvider{diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.phpindex 1dc3b0dd50..4e40f5bec8 100644--- a/app/Providers/RouteServiceProvider.php+++ b/app/Providers/RouteServiceProvider.php@@ -7,6 +7,7 @@ use Illuminate\Routing\Router;* Class RouteServiceProvider** @package FireflyIII\Providers+ * @codeCoverageIgnore*/class RouteServiceProvider extends ServiceProvider{diff --git a/app/Providers/TestingServiceProvider.php b/app/Providers/TestingServiceProvider.phpindex 707c0ddd3f..a548521e04 100644--- a/app/Providers/TestingServiceProvider.php+++ b/app/Providers/TestingServiceProvider.php@@ -8,6 +8,7 @@ use Illuminate\Support\ServiceProvider;/*** Class TestingServiceProvider*+ * @codeCoverageIgnore* @package FireflyIII\Providers*/class TestingServiceProvider extends ServiceProviderdiff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.phpindex f5380a51d1..faa50a7694 100644--- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php+++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php@@ -13,25 +13,20 @@ use Illuminate\Support\Collection;interface PiggyBankRepositoryInterface{- /**- * @return Collection- */- public function getPiggyBanks();-/*** @param PiggyBank $piggyBank+ * @param $amount*- * @return Collection+ * @return bool*/- public function getEvents(PiggyBank $piggyBank);+ public function createEvent(PiggyBank $piggyBank, $amount);/*** @param PiggyBank $piggyBank- * @param $amount** @return bool*/- public function createEvent(PiggyBank $piggyBank, $amount);+ public function destroy(PiggyBank $piggyBank);/*** @param PiggyBank $piggyBank@@ -43,9 +38,14 @@ interface PiggyBankRepositoryInterface/*** @param PiggyBank $piggyBank*- * @return bool+ * @return Collection*/- public function destroy(PiggyBank $piggyBank);+ public function getEvents(PiggyBank $piggyBank);++ /**+ * @return Collection+ */+ public function getPiggyBanks();/*** Set all piggy banks to order 0.diff --git a/tests/controllers/BudgetControllerTest.php b/tests/controllers/BudgetControllerTest.phpindex 7d4bfd2595..6c816feb7f 100644--- a/tests/controllers/BudgetControllerTest.php+++ b/tests/controllers/BudgetControllerTest.php@@ -57,6 +57,24 @@ class BudgetControllerTest extends TestCase}+ /**+ * @covers FireflyIII\Http\Controllers\BudgetController::amount+ */+ public function testAmountZero()+ {+ $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');+ $limitRepetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');+ $budget = $limitRepetition->budgetlimit->budget;+ $this->be($budget->user);+ $today = new Carbon;++ $this->session(['start' => $today]);+ $repository->shouldReceive('updateLimitAmount')->once()->andReturn($limitRepetition);+ $this->call('POST', '/budgets/amount/' . $budget->id, ['amount' => 0, '_token' => 'replaceme']);+ $this->assertResponseOk();++ }+/*** @covers FireflyIII\Http\Controllers\BudgetController::create*/@@ -128,12 +146,13 @@ class BudgetControllerTest extends TestCase$collection = new Collection;$collection->push($budget);$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');+ $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');$repository->shouldReceive('getActiveBudgets')->once()->andReturn($collection);$repository->shouldReceive('getInactiveBudgets')->once()->andReturn($collection);$repository->shouldReceive('cleanupBudgets')->once();$repository->shouldReceive('spentInPeriodCorrected')->once();- $repository->shouldReceive('getCurrentRepetition')->once();+ $repository->shouldReceive('getCurrentRepetition')->once()->andReturn($repetition);Amount::shouldReceive('getCurrencySymbol')->andReturn('x');Amount::shouldReceive('format')->andReturn('x');Amount::shouldReceive('getCurrencyCode')->andReturn('X');diff --git a/tests/controllers/HelpControllerTest.php b/tests/controllers/HelpControllerTest.phpindex 05fc9959fe..b7f40c5f5a 100644--- a/tests/controllers/HelpControllerTest.php+++ b/tests/controllers/HelpControllerTest.php@@ -38,6 +38,7 @@ class HelpControllerTest extends TestCase/*** Everything present and accounted for, and in cache:+ ** @covers FireflyIII\Http\Controllers\HelpController::show*/public function testGetHelpText()@@ -59,6 +60,7 @@ class HelpControllerTest extends TestCase/*** Everything present and accounted for, but not cached+ ** @covers FireflyIII\Http\Controllers\HelpController::show*/public function testGetHelpTextNoCache()@@ -82,6 +84,7 @@ class HelpControllerTest extends TestCase/*** No such route.+ ** @covers FireflyIII\Http\Controllers\HelpController::show*/public function testGetHelpTextNoRoute()diff --git a/tests/controllers/TransactionControllerTest.php b/tests/controllers/TransactionControllerTest.phpindex cbf2c25365..9c672ac1cc 100644--- a/tests/controllers/TransactionControllerTest.php+++ b/tests/controllers/TransactionControllerTest.php@@ -360,16 +360,16 @@ class TransactionControllerTest extends TestCase$account2 = FactoryMuffin::create('FireflyIII\Models\Account');$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');- $piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank');+ $piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank');FactoryMuffin::create('FireflyIII\Models\TransactionType');FactoryMuffin::create('FireflyIII\Models\TransactionType');- $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');$this->be($account->user);$account2->user_id = $account->user_id;$account->account_type_id = $asset->id;$account2->account_type_id = $asset->id;- $piggy->account_id = $account->id;+ $piggy->account_id = $account->id;$account->save();$account2->save();$piggy->save();diff --git a/tests/helpers/ReportHelperTest.php b/tests/helpers/ReportHelperTest.phpindex b8af8b6f50..9f5134f0c2 100644--- a/tests/helpers/ReportHelperTest.php+++ b/tests/helpers/ReportHelperTest.php@@ -233,16 +233,20 @@ class ReportHelperTest extends TestCase$left->save();// save meta for account:- AccountMeta::create([- 'account_id' => $left->id,- 'name' => 'accountRole',- 'data' => 'defaultAsset'- ]);- AccountMeta::create([- 'account_id' => $right->id,- 'name' => 'accountRole',- 'data' => 'defaultAsset'- ]);+ AccountMeta::create(+ [+ 'account_id' => $left->id,+ 'name' => 'accountRole',+ 'data' => 'defaultAsset'+ ]+ );+ AccountMeta::create(+ [+ 'account_id' => $right->id,+ 'name' => 'accountRole',+ 'data' => 'defaultAsset'+ ]+ );for ($i = 0; $i < 5; $i++) {@@ -292,16 +296,20 @@ class ReportHelperTest extends TestCase$right->account_type_id = $asset->id;// save meta for account:- AccountMeta::create([- 'account_id' => $left->id,- 'name' => 'accountRole',- 'data' => 'defaultAsset'- ]);- AccountMeta::create([- 'account_id' => $right->id,- 'name' => 'accountRole',- 'data' => 'defaultAsset'- ]);+ AccountMeta::create(+ [+ 'account_id' => $left->id,+ 'name' => 'accountRole',+ 'data' => 'defaultAsset'+ ]+ );+ AccountMeta::create(+ [+ 'account_id' => $right->id,+ 'name' => 'accountRole',+ 'data' => 'defaultAsset'+ ]+ );$right->save();$left->save();diff --git a/tests/models/AccountModelTest.php b/tests/models/AccountModelTest.phpindex aca43a7595..82636cf799 100644--- a/tests/models/AccountModelTest.php+++ b/tests/models/AccountModelTest.php@@ -76,7 +76,7 @@ class AccountModelTest extends TestCase'name' => 'Some new account','account_type_id' => $account->account_type_id,'user_id' => $account->user_id,- 'active' => 1,+ 'active' => 1,];$result = Account::firstOrCreateEncrypted($search);@@ -125,7 +125,7 @@ class AccountModelTest extends TestCase'name' => 'Some new account','account_type_id' => $account->account_type_id,'user_id' => $account->user_id,- 'active' => 1,+ 'active' => 1,];$result = Account::firstOrNullEncrypted($search);diff --git a/tests/models/TagModelTest.php b/tests/models/TagModelTest.phpindex d9b42ed2c3..c0d7db2afa 100644--- a/tests/models/TagModelTest.php+++ b/tests/models/TagModelTest.php@@ -41,37 +41,37 @@ class TagModelTest extends TestCase/*** @covers FireflyIII\Models\Tag::firstOrCreateEncrypted*/- public function testFirstOrCreateEncryptedNew()+ public function testFirstOrCreateEncrypted(){$tag = FactoryMuffin::create('FireflyIII\Models\Tag');$search = ['tagMode' => 'something',- 'tag' => 'Something else',+ 'tag' => $tag->tag,'user_id' => $tag->user_id,];$result = Tag::firstOrCreateEncrypted($search);- $this->assertNotEquals($tag->id, $result->id);+ $this->assertEquals($tag->id, $result->id);}/*** @covers FireflyIII\Models\Tag::firstOrCreateEncrypted*/- public function testFirstOrCreateEncrypted()+ public function testFirstOrCreateEncryptedNew(){$tag = FactoryMuffin::create('FireflyIII\Models\Tag');$search = ['tagMode' => 'something',- 'tag' => $tag->tag,+ 'tag' => 'Something else','user_id' => $tag->user_id,];$result = Tag::firstOrCreateEncrypted($search);- $this->assertEquals($tag->id, $result->id);+ $this->assertNotEquals($tag->id, $result->id);}}diff --git a/tests/models/TransactionJournalModelTest.php b/tests/models/TransactionJournalModelTest.phpindex 0b7094cc3a..e9d625f616 100644--- a/tests/models/TransactionJournalModelTest.php+++ b/tests/models/TransactionJournalModelTest.php@@ -324,7 +324,7 @@ class TransactionJournalModelTest extends TestCase// make accounts$expense = FactoryMuffin::create('FireflyIII\Models\Account');FactoryMuffin::create('FireflyIII\Models\Account');- $asset = FactoryMuffin::create('FireflyIII\Models\Account');+ $asset = FactoryMuffin::create('FireflyIII\Models\Account');Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 300]);Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -300]);diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.phpindex 6dc39fab38..59b1b53973 100644--- a/tests/repositories/AccountRepositoryTest.php+++ b/tests/repositories/AccountRepositoryTest.php@@ -58,8 +58,8 @@ class AccountRepositoryTest extends TestCasepublic function testDestroy(){// create account:- $account = FactoryMuffin::create('FireflyIII\Models\Account');- $accountId = $account->id;+ $account = FactoryMuffin::create('FireflyIII\Models\Account');+ $accountId = $account->id;$this->be($account->user);diff --git a/tests/repositories/BillRepositoryTest.php b/tests/repositories/BillRepositoryTest.phpindex c8f32f6d92..5c2c1df2de 100644--- a/tests/repositories/BillRepositoryTest.php+++ b/tests/repositories/BillRepositoryTest.php@@ -43,8 +43,8 @@ class BillRepositoryTest extends TestCase$end = Carbon::now()->endOfMonth();// payment:- $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');- $journal->date = $start;+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');+ $journal->date = $start;$journal->bill_id = $bill->id;$journal->save();diff --git a/tests/repositories/CategoryRepositoryTest.php b/tests/repositories/CategoryRepositoryTest.phpindex 520ca1dbea..6e235007ef 100644--- a/tests/repositories/CategoryRepositoryTest.php+++ b/tests/repositories/CategoryRepositoryTest.php@@ -103,7 +103,7 @@ class CategoryRepositoryTest extends TestCase$journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');$journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');/** @var Category $category */- $category = FactoryMuffin::create('FireflyIII\Models\Category');+ $category = FactoryMuffin::create('FireflyIII\Models\Category');$journal1->user_id = $user->id;$journal1->date = new Carbon('2015-02-11');@@ -113,7 +113,7 @@ class CategoryRepositoryTest extends TestCase$journal2->date = new Carbon('2015-02-11');$journal2->transaction_type_id = $type->id;- $category->user_id = $user->id;+ $category->user_id = $user->id;$category->transactionjournals()->save($journal1);$category->transactionjournals()->save($journal2);diff --git a/tests/repositories/TagRepositoryTest.php b/tests/repositories/TagRepositoryTest.phpindex d38b71f989..a1dbfc0bcb 100644--- a/tests/repositories/TagRepositoryTest.php+++ b/tests/repositories/TagRepositoryTest.php@@ -58,7 +58,7 @@ class TagRepositoryTest extends TestCasepublic function testConnectBalancingOneDeposit(){FactoryMuffin::create('FireflyIII\Models\TransactionType');- $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');FactoryMuffin::create('FireflyIII\Models\TransactionType');$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');@@ -85,7 +85,7 @@ class TagRepositoryTest extends TestCase{FactoryMuffin::create('FireflyIII\Models\TransactionType');FactoryMuffin::create('FireflyIII\Models\TransactionType');- $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');$tag = FactoryMuffin::create('FireflyIII\Models\Tag');@@ -156,7 +156,7 @@ class TagRepositoryTest extends TestCaseFactoryMuffin::create('FireflyIII\Models\AccountType');FactoryMuffin::create('FireflyIII\Models\AccountType');- $asset = FactoryMuffin::create('FireflyIII\Models\AccountType');+ $asset = FactoryMuffin::create('FireflyIII\Models\AccountType');$account = FactoryMuffin::create('FireflyIII\Models\Account');@@ -203,7 +203,7 @@ class TagRepositoryTest extends TestCaseFactoryMuffin::create('FireflyIII\Models\AccountType');FactoryMuffin::create('FireflyIII\Models\AccountType');- $asset = FactoryMuffin::create('FireflyIII\Models\AccountType');+ $asset = FactoryMuffin::create('FireflyIII\Models\AccountType');$account1 = FactoryMuffin::create('FireflyIII\Models\Account');$account2 = FactoryMuffin::create('FireflyIII\Models\Account');@@ -248,7 +248,7 @@ class TagRepositoryTest extends TestCase{FactoryMuffin::create('FireflyIII\Models\TransactionType');FactoryMuffin::create('FireflyIII\Models\TransactionType');- $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');$tag = FactoryMuffin::create('FireflyIII\Models\Tag');