mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Improve test coverage.
This commit is contained in:
@@ -61,12 +61,14 @@ class JobStatusControllerTest extends TestCase
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Afake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Afake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
|
||||
// call thing.
|
||||
@@ -86,13 +88,15 @@ class JobStatusControllerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Bfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Bfake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'file';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$importRepos->shouldReceive('countTransactions')->once()->andReturn(0);
|
||||
|
||||
// call thing.
|
||||
@@ -114,7 +118,7 @@ class JobStatusControllerTest extends TestCase
|
||||
$tag = $this->user()->tags()->first();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Cfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Cfake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
@@ -122,6 +126,8 @@ class JobStatusControllerTest extends TestCase
|
||||
$job->tag()->associate($tag);
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$importRepos->shouldReceive('countTransactions')->once()->andReturn(0);
|
||||
|
||||
// call thing.
|
||||
@@ -147,11 +153,13 @@ class JobStatusControllerTest extends TestCase
|
||||
$second = $this->user()->transactionJournals()->where('id', '!=', $journal->id)->first();
|
||||
$tag->transactionJournals()->sync([$journal->id, $second->id]);
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$importRepos->shouldReceive('countTransactions')->once()->andReturn(2);
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Dfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Dfake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
@@ -181,11 +189,13 @@ class JobStatusControllerTest extends TestCase
|
||||
$journal = $this->user()->transactionJournals()->first();
|
||||
$tag->transactionJournals()->sync([$journal->id]);
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$importRepos->shouldReceive('countTransactions')->once()->andReturn(1);
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Efake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Efake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
@@ -211,13 +221,15 @@ class JobStatusControllerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Ffake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Ffake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$routine = $this->mock(FakeRoutine::class);
|
||||
@@ -242,13 +254,15 @@ class JobStatusControllerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Gfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Gfake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$routine = $this->mock(FakeRoutine::class);
|
||||
@@ -273,13 +287,15 @@ class JobStatusControllerTest extends TestCase
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Hfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Hfake_job_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$routine = $this->mock(FakeRoutine::class);
|
||||
@@ -307,9 +323,11 @@ class JobStatusControllerTest extends TestCase
|
||||
$importRepos->shouldReceive('setStatus')->withArgs([Mockery::any(), 'error'])
|
||||
->atLeast()->once();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Ifake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Ifake_job_' . $this->randomInt();
|
||||
$job->status = 'bad_state';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
@@ -330,13 +348,15 @@ class JobStatusControllerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Jfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Jfake_job_' . $this->randomInt();
|
||||
$job->status = 'provider_finished';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$storage = $this->mock(ImportArrayStorage::class);
|
||||
@@ -362,13 +382,15 @@ class JobStatusControllerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Lfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Lfake_job_' . $this->randomInt();
|
||||
$job->status = 'provider_finished';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$storage = $this->mock(ImportArrayStorage::class);
|
||||
@@ -395,13 +417,15 @@ class JobStatusControllerTest extends TestCase
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Kfake_job_' . random_int(1, 10000);
|
||||
$job->key = 'Kfake_job_' . $this->randomInt();
|
||||
$job->status = 'some_bad_state';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.job.store', [$job->key]));
|
||||
$response->assertStatus(200);
|
||||
|
||||
Reference in New Issue
Block a user