Improve test coverage.

This commit is contained in:
James Cole
2019-06-29 08:14:28 +02:00
parent cf904eb677
commit 003d07504f
33 changed files with 447 additions and 269 deletions

View File

@@ -70,6 +70,8 @@ class IndexControllerTest extends TestCase
$importJob->provider = 'fake';
$importJob->key = 'fake_job_1';
$this->mockDefaultSession();
// mock calls:
$ynabPrerequisites->shouldReceive('setUser')->once();
$fakePrerequisites->shouldReceive('setUser')->once();
@@ -105,6 +107,8 @@ class IndexControllerTest extends TestCase
$importJob->provider = 'spectre';
$importJob->key = 'fake_job_1';
$this->mockDefaultSession();
// mock calls:
$ynabPrerequisites->shouldReceive('setUser')->times(2);
$fakePrerequisites->shouldReceive('setUser')->times(2);
@@ -143,6 +147,8 @@ class IndexControllerTest extends TestCase
$importJob->key = 'fake_job_1';
$importJob->user_id = 1;
$this->mockDefaultSession();
// mock calls
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(true)->times(3);
@@ -188,6 +194,8 @@ class IndexControllerTest extends TestCase
$importJob->key = 'fake_job_2';
$importJob->user_id = 1;
$this->mockDefaultSession();
// mock call:
$fakePrerequisites->shouldReceive('isComplete')->times(3)->andReturn(true);
@@ -235,6 +243,8 @@ class IndexControllerTest extends TestCase
$importJob->key = 'file_job_1';
$importJob->user_id = 1;
$this->mockDefaultSession();
// mock calls
$fakePrerequisites->shouldReceive('setUser')->times(2);
$bunqPrerequisites->shouldReceive('setUser')->times(2);
@@ -272,9 +282,11 @@ class IndexControllerTest extends TestCase
$filePrerequisites = $this->mock(FilePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
$this->mockDefaultSession();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'dc_' . random_int(1, 10000);
$job->key = 'dc_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'file';
@@ -325,6 +337,8 @@ class IndexControllerTest extends TestCase
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
$this->mockDefaultSession();
// call methods:
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false);
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(false);
@@ -360,6 +374,8 @@ class IndexControllerTest extends TestCase
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
$this->mockDefaultSession();
// call methods:
$fakePrerequisites->shouldReceive('setUser')->once();
$bunqPrerequisites->shouldReceive('setUser')->once();