mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 12:11:19 +00:00
Optimise tests and coverage.
This commit is contained in:
@@ -46,7 +46,7 @@ class FakeRoutineTest extends TestCase
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'a_route_' . random_int(1, 1000);
|
||||
$job->status = 'running';
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'ahoy';
|
||||
$job->provider = 'fake';
|
||||
$job->file_type = '';
|
||||
@@ -59,6 +59,7 @@ class FakeRoutineTest extends TestCase
|
||||
|
||||
// calls
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
|
||||
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
|
||||
$handler->shouldReceive('run')->once();
|
||||
@@ -81,7 +82,7 @@ class FakeRoutineTest extends TestCase
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'a_route_' . random_int(1, 1000);
|
||||
$job->status = 'running';
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'final';
|
||||
$job->provider = 'fake';
|
||||
$job->file_type = '';
|
||||
@@ -98,6 +99,7 @@ class FakeRoutineTest extends TestCase
|
||||
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
|
||||
$repository->shouldReceive('setTransactions')->withArgs([Mockery::any(), []])->once();
|
||||
$handler->shouldReceive('getTransactions')->once()->andReturn([]);
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
|
||||
$handler->shouldReceive('setImportJob')->once();
|
||||
|
||||
$routine = new FakeRoutine;
|
||||
@@ -117,7 +119,7 @@ class FakeRoutineTest extends TestCase
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'a_route_' . random_int(1, 1000);
|
||||
$job->status = 'running';
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
$job->file_type = '';
|
||||
@@ -132,6 +134,7 @@ class FakeRoutineTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'ahoy'])->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'ready_to_run'])->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
|
||||
$handler->shouldReceive('run')->once();
|
||||
|
||||
|
||||
|
@@ -46,7 +46,7 @@ class FileRoutineTest extends TestCase
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'a_fr_' . random_int(1, 1000);
|
||||
$job->status = 'running';
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'ready_to_run';
|
||||
$job->provider = 'file';
|
||||
$job->file_type = '';
|
||||
@@ -59,6 +59,7 @@ class FileRoutineTest extends TestCase
|
||||
|
||||
// calls
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'provider_finished'])->once();
|
||||
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
|
||||
$repository->shouldReceive('setTransactions')->withArgs([Mockery::any(), ['a' => 'b']])->once();
|
||||
|
@@ -128,7 +128,7 @@ class ImportArrayStorageTest extends TestCase
|
||||
$journalRepos->shouldReceive('store')->once()->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findByHash')->andReturn(null, $meta)->twice();
|
||||
$repository->shouldReceive('addErrorMessage')->once()
|
||||
->withArgs([Mockery::any(), 'Entry #1 ("' . $transactions[1]['description'] . '") could not be imported. It already exists.']);
|
||||
->withArgs([Mockery::any(), 'Row #1 ("' . $transactions[1]['description'] . '") could not be imported. It already exists.']);
|
||||
|
||||
$storage = new ImportArrayStorage;
|
||||
$storage->setImportJob($job);
|
||||
@@ -374,6 +374,7 @@ class ImportArrayStorageTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$collector->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStatus')->withAnyArgs();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
@@ -449,6 +450,7 @@ class ImportArrayStorageTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$collector->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStatus')->withAnyArgs();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
@@ -460,7 +462,7 @@ class ImportArrayStorageTest extends TestCase
|
||||
$journalRepos->shouldReceive('store')->twice()->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findByHash')->andReturn(null)->times(3);
|
||||
$repository->shouldReceive('addErrorMessage')->withArgs(
|
||||
[Mockery::any(), 'Entry #2 ("' . $transfer->description . '") could not be imported. Such a transfer already exists.']
|
||||
[Mockery::any(), 'Row #2 ("' . $transfer->description . '") could not be imported. Such a transfer already exists.']
|
||||
)->once();
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user