Fix test coverage.

This commit is contained in:
James Cole 2019-01-01 18:03:24 +01:00
parent bf257574f9
commit d7bf9e234c
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 18 additions and 1 deletions

View File

@ -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++;
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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();