Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expanded some tests.
James Cole54c6ca9f4590
diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.phpindex 78f4295ea2..0dcaddb3f7 100644--- a/app/Helpers/Report/ReportQuery.php+++ b/app/Helpers/Report/ReportQuery.php@@ -74,7 +74,9 @@ class ReportQuery implements ReportQueryInterfaceif ($journal->amount != 0) {return $journal;}+ // @codeCoverageIgnoreStart}+ // @codeCoverageIgnoreEnd);return $data;@@ -191,7 +193,9 @@ class ReportQuery implements ReportQueryInterfaceif ($journal->amount != 0) {return $journal;}+ // @codeCoverageIgnoreStart}+ // @codeCoverageIgnoreEnd);return $data;@@ -237,14 +241,11 @@ class ReportQuery implements ReportQueryInterfaceAuth::user()->transactionjournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.amount', '<', 0)->transactionTypes(['Withdrawal'])->where('transactions.account_id', $account->id)->before($end)->after($start)- ->whereNull('budget_transaction_journal.budget_id')- ->sum('transactions.amount')- );+ ->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount'));}/**diff --git a/app/Http/Middleware/Cleanup.php b/app/Http/Middleware/Cleanup.phpindex 74dfefc414..c7e0f01d52 100644--- a/app/Http/Middleware/Cleanup.php+++ b/app/Http/Middleware/Cleanup.php@@ -148,8 +148,8 @@ class Cleanup}unset($set, $entry, $metadata);-//encrypt budget limit amount+//encrypt limit repetition amount//encrypt piggy bank event amount//encrypt piggy bank repetition currentamountdiff --git a/tests/factories/all.php b/tests/factories/all.phpindex 0250e1bac3..986efab4a4 100644--- a/tests/factories/all.php+++ b/tests/factories/all.php@@ -192,7 +192,7 @@ FactoryMuffin::define(return RandomString::generateRandomString(3);},'symbol' => function () {- return RandomString::generateRandomString(1);+ return RandomString::generateRandomString(2);},'name' => 'word']diff --git a/tests/helpers/ReportHelperTest.php b/tests/helpers/ReportHelperTest.phpindex 9fc169d107..174dc6ae99 100644--- a/tests/helpers/ReportHelperTest.php+++ b/tests/helpers/ReportHelperTest.php@@ -70,6 +70,7 @@ class ReportHelperTest extends TestCase* @covers FireflyIII\Helpers\Report\ReportHelper::getBalanceReport* @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts* @covers FireflyIII\Helpers\Report\ReportQuery::spentInBudgetCorrected+ * @covers FireflyIII\Helpers\Report\ReportQuery::spentNoBudget*/public function testGetBalanceReport(){diff --git a/tests/repositories/BillRepositoryTest.php b/tests/repositories/BillRepositoryTest.phpindex 9a3abaaea8..c8f32f6d92 100644--- a/tests/repositories/BillRepositoryTest.php+++ b/tests/repositories/BillRepositoryTest.php@@ -36,6 +36,22 @@ class BillRepositoryTest extends TestCaseparent::tearDown();}+ public function testBillPaymentsInRange()+ {+ $bill = FactoryMuffin::create('FireflyIII\Models\Bill');+ $start = Carbon::now()->startOfMonth();+ $end = Carbon::now()->endOfMonth();++ // payment:+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');+ $journal->date = $start;+ $journal->bill_id = $bill->id;+ $journal->save();+++ $this->object->billPaymentsInRange($bill, $start, $end);+ }+/*** @covers FireflyIII\Repositories\Bill\BillRepository::createFakeBill*/@@ -58,8 +74,8 @@ class BillRepositoryTest extends TestCase*/public function testDestroy(){- $bill = FactoryMuffin::create('FireflyIII\Models\Bill');- $accountId = $bill->id;+ $bill = FactoryMuffin::create('FireflyIII\Models\Bill');+ $accountId = $bill->id;$this->object->destroy($bill);// cannot find bill:@@ -284,6 +300,7 @@ class BillRepositoryTest extends TestCase/*** One* @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ ** @covers FireflyIII\Repositories\Bill\BillRepository::scan*/public function testScanMatch()diff --git a/tests/repositories/BudgetRepositoryTest.php b/tests/repositories/BudgetRepositoryTest.phpindex d16ae370df..8008d78f11 100644--- a/tests/repositories/BudgetRepositoryTest.php+++ b/tests/repositories/BudgetRepositoryTest.php@@ -295,7 +295,18 @@ class BudgetRepositoryTest extends TestCase{$budget = FactoryMuffin::create('FireflyIII\Models\Budget');- $amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon);+ $amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon, false);+ $this->assertEquals(0, $amount);+ }++ /**+ * @covers FireflyIII\Repositories\Budget\BudgetRepository::spentInPeriodCorrected+ */+ public function testSpentInPeriodCorrectedShared()+ {+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');++ $amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon, true);$this->assertEquals(0, $amount);}diff --git a/tests/repositories/CategoryRepositoryTest.php b/tests/repositories/CategoryRepositoryTest.phpindex 0e5b0d92a1..f3681d0e02 100644--- a/tests/repositories/CategoryRepositoryTest.php+++ b/tests/repositories/CategoryRepositoryTest.php@@ -99,6 +99,15 @@ class CategoryRepositoryTest extends TestCase$category->save();}+ // another journal, same category:+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');+ $journal->user_id = $user->id;+ $journal->date = new Carbon('2015-02-11');+ $journal->transaction_type_id = $type->id;+ $category->transactionjournals()->save($journal);+ $journal->save();+ $category->save();+$this->be($user);$set = $this->object->getCategoriesAndExpensesCorrected(new Carbon('2015-02-01'), new Carbon('2015-02-28'));$this->assertCount(5, $set);@@ -196,7 +205,20 @@ class CategoryRepositoryTest extends TestCasepublic function testSpentInPeriodSumCorrected(){$category = FactoryMuffin::create('FireflyIII\Models\Category');- $sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon);+ $sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon, false);++ $this->assertEquals(0, $sum);+++ }++ /**+ * @covers FireflyIII\Repositories\Category\CategoryRepository::spentInPeriodCorrected+ */+ public function testSpentInPeriodSumCorrectedShared()+ {+ $category = FactoryMuffin::create('FireflyIII\Models\Category');+ $sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon, true);$this->assertEquals(0, $sum);