mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Fix test coverage.
This commit is contained in:
		| @@ -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()); | ||||
|   | ||||
| @@ -104,6 +104,7 @@ class NewUserControllerTest extends TestCase | ||||
|         $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', | ||||
| @@ -133,6 +134,7 @@ class NewUserControllerTest extends TestCase | ||||
|         $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', | ||||
| @@ -161,6 +163,7 @@ class NewUserControllerTest extends TestCase | ||||
|         $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); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user