Fix test coverage.

This commit is contained in:
James Cole
2018-11-10 15:15:29 +01:00
parent 45699f13fc
commit 7380c5096e
4 changed files with 23 additions and 15 deletions

View File

@@ -80,7 +80,7 @@ class CurrencyControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('canDeleteCurrency')->andReturn(false);
$repository->shouldReceive('currencyInUse')->andReturn(true);
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
$this->be($this->user());
@@ -100,7 +100,7 @@ class CurrencyControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('canDeleteCurrency')->andReturn(false);
$repository->shouldReceive('currencyInUse')->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
@@ -142,6 +142,7 @@ class CurrencyControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$currencyRepos->shouldReceive('enable')->once();
$this->be($this->user());
$response = $this->get(route('currencies.default', [1]));
@@ -160,7 +161,7 @@ class CurrencyControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('canDeleteCurrency')->andReturn(true);
$repository->shouldReceive('currencyInUse')->andReturn(false);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(2)->andReturn(true);
$this->be($this->user());
@@ -180,7 +181,7 @@ class CurrencyControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('canDeleteCurrency')->andReturn(true);
$repository->shouldReceive('currencyInUse')->andReturn(false);
$repository->shouldReceive('destroy')->andReturn(true)->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(1)->andReturn(true);
@@ -227,7 +228,7 @@ class CurrencyControllerTest extends TestCase
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getCurrencyByPreference')->andReturn($currencies->first());
$repository->shouldReceive('get')->andReturn($currencies);
$repository->shouldReceive('getAll')->andReturn($currencies);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(2)->andReturn(true);
$this->be($this->user());
@@ -250,7 +251,7 @@ class CurrencyControllerTest extends TestCase
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
$repository->shouldReceive('get')->andReturn(new Collection);
$repository->shouldReceive('getAll')->andReturn(new Collection);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(2)->andReturn(false);
$this->be($this->user());

View File

@@ -59,7 +59,7 @@ class NewUserControllerTest extends TestCase
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('count')->andReturn(0);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -79,7 +79,7 @@ class NewUserControllerTest extends TestCase
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('count')->andReturn(1);
@@ -99,11 +99,12 @@ class NewUserControllerTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('store')->times(3);
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
$currencyRepos->shouldReceive('enable')->once();
$data = [
'bank_name' => 'New bank',
@@ -127,12 +128,13 @@ class NewUserControllerTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('store')->times(3);
$currencyRepos->shouldReceive('findNull')->andReturn(null);
$currencyRepos->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(TransactionCurrency::find(2))->once();
$currencyRepos->shouldReceive('enable')->once();
$data = [
'bank_name' => 'New bank',
@@ -156,11 +158,12 @@ class NewUserControllerTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('store')->times(3);
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
$currencyRepos->shouldReceive('enable')->once();
$data = [
'bank_name' => 'New bank',