mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 01:41:14 -06:00
Fix test coverage.
This commit is contained in:
parent
45699f13fc
commit
7380c5096e
@ -65,7 +65,7 @@ class CurrencyControllerTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->once()->withArgs([Mockery::any(), 'owner'])->andReturn(true);
|
||||
$repository->shouldReceive('canDeleteCurrency')->once()->andReturn(true);
|
||||
$repository->shouldReceive('currencyInUse')->once()->andReturn(false);
|
||||
|
||||
$repository->shouldReceive('destroy')->once()->andReturn(true);
|
||||
|
||||
@ -91,7 +91,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('get')->withNoArgs()->andReturn($collection)->once();
|
||||
$repository->shouldReceive('getAll')->withNoArgs()->andReturn($collection)->once();
|
||||
|
||||
// test API
|
||||
$response = $this->get('/api/v1/currencies');
|
||||
@ -167,6 +167,7 @@ class CurrencyControllerTest extends TestCase
|
||||
'symbol' => 'A',
|
||||
'decimal_places' => 2,
|
||||
'default' => '0',
|
||||
'enabled' => '1',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -206,6 +207,7 @@ class CurrencyControllerTest extends TestCase
|
||||
'symbol' => 'A',
|
||||
'decimal_places' => 2,
|
||||
'default' => '1',
|
||||
'enabled' => '1',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -239,6 +241,7 @@ class CurrencyControllerTest extends TestCase
|
||||
'symbol' => '$E',
|
||||
'decimal_places' => '2',
|
||||
'default' => '0',
|
||||
'enabled' => '1',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -278,6 +281,7 @@ class CurrencyControllerTest extends TestCase
|
||||
'symbol' => '$E',
|
||||
'decimal_places' => '2',
|
||||
'default' => '1',
|
||||
'enabled' => '1',
|
||||
];
|
||||
|
||||
// test API
|
||||
|
@ -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());
|
||||
|
@ -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',
|
||||
|
@ -51,7 +51,7 @@ class TransactionCurrencyFactoryTest extends TestCase
|
||||
{
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$result = $factory->create(['name' => 'OK', 'code' => 'XXA', 'symbol' => 'Z', 'decimal_places' => 2]);
|
||||
$result = $factory->create(['name' => 'OK', 'code' => 'XXA', 'symbol' => 'Z', 'decimal_places' => 2, 'enabled' => true]);
|
||||
$this->assertNotNull($result);
|
||||
$this->assertEquals('XXA', $result->code);
|
||||
}
|
||||
@ -63,7 +63,7 @@ class TransactionCurrencyFactoryTest extends TestCase
|
||||
{
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$result = $factory->create(['name' => null, 'code' => null, 'symbol' => null, 'decimal_places' => null]);
|
||||
$result = $factory->create(['name' => null, 'code' => null, 'symbol' => null, 'decimal_places' => null, 'enabled' => true]);
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user