Various code coverage changes and code updates.

This commit is contained in:
James Cole
2018-07-12 21:32:58 +02:00
parent 0217d9396a
commit 5846431b34
20 changed files with 398 additions and 224 deletions

View File

@@ -92,6 +92,8 @@ class UserEventHandlerTest extends TestCase
$listener = new UserEventHandler();
// mock stuff
$repository->shouldReceive('hasRole')->once()->andReturn(false);
$repository->shouldReceive('count')->once()->andReturn(1);
$repository->shouldReceive('getRole')->once()->andReturn(null);
$repository->shouldReceive('attachRole')->once()->withArgs([Mockery::any(), 'owner']);
@@ -112,6 +114,7 @@ class UserEventHandlerTest extends TestCase
$listener = new UserEventHandler();
// mock stuff
$repository->shouldReceive('hasRole')->once()->andReturn(false);
$repository->shouldReceive('count')->once()->andReturn(1);
$repository->shouldReceive('getRole')->once()->andReturn(new Role);
$repository->shouldReceive('attachRole')->once()->withArgs([Mockery::any(), 'owner']);
@@ -131,6 +134,7 @@ class UserEventHandlerTest extends TestCase
$listener = new UserEventHandler();
// mock stuff
$repository->shouldReceive('hasRole')->once()->andReturn(true);
$repository->shouldReceive('count')->once()->andReturn(1);
$listener->checkSingleUserIsAdmin($event);

View File

@@ -59,10 +59,11 @@ class VersionCheckEventHandlerTest extends TestCase
// report on config variables:
FireflyConfig::shouldReceive('get')->withArgs(['permission_update_check', -1])->once()->andReturn($updateConfig);
FireflyConfig::shouldReceive('get')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn($checkConfig);
FireflyConfig::shouldReceive('set')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn($checkConfig);
// request thing:
$request->shouldReceive('call')->once();
$request->shouldReceive('getReleases')->once()->andThrow(new FireflyException('Errrr'));
$request->shouldReceive('call')->once()->andThrow(new FireflyException('Errrr'));
$request->shouldReceive('getReleases')->once();
$handler = new VersionCheckEventHandler;
@@ -140,6 +141,7 @@ class VersionCheckEventHandlerTest extends TestCase
// report on config variables:
FireflyConfig::shouldReceive('get')->withArgs(['permission_update_check', -1])->once()->andReturn($updateConfig);
FireflyConfig::shouldReceive('get')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn($checkConfig);
FireflyConfig::shouldReceive('set')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn($checkConfig);
$handler = new VersionCheckEventHandler;
$handler->checkForUpdates($event);
@@ -164,6 +166,7 @@ class VersionCheckEventHandlerTest extends TestCase
// report on config variables:
FireflyConfig::shouldReceive('get')->withArgs(['permission_update_check', -1])->once()->andReturn($updateConfig);
FireflyConfig::shouldReceive('get')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn($checkConfig);
FireflyConfig::shouldReceive('set')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn($checkConfig);
$handler = new VersionCheckEventHandler;
$handler->checkForUpdates($event);

View File

@@ -127,8 +127,8 @@ class SandstormTest extends TestCase
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('count')->twice()->andReturn(0);
$repository->shouldReceive('store')->once()->andReturn($this->user());
$repository->shouldReceive('attachRole')->twice()->andReturn(true);
$repository->shouldReceive('getRole')->once()->andReturn(new Role);
$repository->shouldReceive('attachRole')->once()->andReturn(true);
//$repository->shouldReceive('getRole')->once()->andReturn(new Role);
$repository->shouldReceive('hasRole')->andReturn(false);
$response = $this->get('/_test/sandstorm', ['X-Sandstorm-User-Id' => 'abcd']);

View File

@@ -72,10 +72,12 @@ class ToAccountStartsTest extends TestCase
$count = $journal->transactions()->where('amount', '>', 0)->count();
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
$account = null === $transaction ? null : $transaction->account;
Log::debug(sprintf('Journal with id #%d', $journal->id));
Log::debug(sprintf('Count of transactions is %d', $count));
Log::debug(sprintf('Account is null: %s', var_export(null === $account, true)));
} while ($loopCount < 30 && $count !== 1 && null !== $account);
} while ($loopCount < 30 && $count < 1 && null !== $account);
Log::debug(sprintf('Loop has ended. loopCount is %d', $loopCount));
$trigger = ToAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false);