mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix test coverage.
This commit is contained in:
parent
bf257574f9
commit
d7bf9e234c
@ -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++;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user