Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix test coverage.
James Coled7bf9e234cfe
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex cac645acdd..4f46b3fc1e 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -115,7 +115,7 @@ trait TransactionValidation$journalDescription = (string)($data['description'] ?? null);$validDescriptions = 0;foreach ($transactions as $index => $transaction) {- if (\strlen((string)($transaction['description'] ?? null)) > 0) {+ if ('' !== (string)($transaction['description'] ?? null)) {$validDescriptions++;}}diff --git a/tests/Feature/Controllers/Category/NoCategoryControllerTest.php b/tests/Feature/Controllers/Category/NoCategoryControllerTest.phpindex 5d27766853..50b5b97053 100644--- a/tests/Feature/Controllers/Category/NoCategoryControllerTest.php+++ b/tests/Feature/Controllers/Category/NoCategoryControllerTest.php@@ -71,7 +71,10 @@ class NoCategoryControllerTest extends TestCase$accountRepos = $this->mock(AccountRepositoryInterface::class);$journalRepos = $this->mock(JournalRepositoryInterface::class);$userRepos = $this->mock(UserRepositoryInterface::class);+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);// get the journal with the most recent date for firstNull:$journal = $this->user()->transactionJournals()->orderBy('date', 'DESC')->first();@@ -116,6 +119,9 @@ class NoCategoryControllerTest extends TestCase$userRepos = $this->mock(UserRepositoryInterface::class);$fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);+$journalRepos->shouldReceive('firstNull')->twice()->andReturn(TransactionJournal::first());$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();diff --git a/tests/Feature/Controllers/Category/ShowControllerTest.php b/tests/Feature/Controllers/Category/ShowControllerTest.phpindex 85c0a0a3d0..89a794ec71 100644--- a/tests/Feature/Controllers/Category/ShowControllerTest.php+++ b/tests/Feature/Controllers/Category/ShowControllerTest.php@@ -71,6 +71,9 @@ class ShowControllerTest extends TestCase$accountRepos = $this->mock(AccountRepositoryInterface::class);$journalRepos = $this->mock(JournalRepositoryInterface::class);$userRepos = $this->mock(UserRepositoryInterface::class);+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);@@ -129,6 +132,8 @@ class ShowControllerTest extends TestCase$accountRepos = $this->mock(AccountRepositoryInterface::class);$userRepos = $this->mock(UserRepositoryInterface::class);$fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);@@ -226,6 +231,8 @@ class ShowControllerTest extends TestCase$repository = $this->mock(CategoryRepositoryInterface::class);$collector = $this->mock(TransactionCollectorInterface::class);$fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);diff --git a/tests/Feature/Controllers/Chart/AccountControllerTest.php b/tests/Feature/Controllers/Chart/AccountControllerTest.phpindex 9faa929729..02a56627fe 100644--- a/tests/Feature/Controllers/Chart/AccountControllerTest.php+++ b/tests/Feature/Controllers/Chart/AccountControllerTest.php@@ -239,6 +239,8 @@ class AccountControllerTest extends TestCase$accountRepos = $this->mock(AccountRepositoryInterface::class);$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);$fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);// change the preference:Preferences::setForUser($this->user(), 'frontPageAccounts', []);@@ -381,6 +383,8 @@ class AccountControllerTest extends TestCase$accountRepos = $this->mock(AccountRepositoryInterface::class);$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);$fiscalHelper = $this->mock(FiscalHelperInterface::class);+ $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon);+ $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon);// grab two expense accounts from the current user.$accounts = $this->user()->accounts()->where('account_type_id', 5)->take(2)->get();