Expand test coverage.

This commit is contained in:
James Cole
2018-06-01 22:04:52 +02:00
parent 2a05cc382f
commit a7b8470d9e
31 changed files with 951 additions and 173 deletions

View File

@@ -191,6 +191,43 @@ class IndexControllerTest extends TestCase
$response->assertRedirect(route('import.job.configuration.index', ['file_job_1']));
}
/**
* @covers \FireflyIII\Http\Controllers\Import\IndexController
*/
public function testDownload(): void
{
// mock stuff:
$repository = $this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'dc_' . random_int(1, 1000);
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'file';
$job->file_type = '';
$job->configuration = [];
$job->save();
$fakeConfig = [
'hi' => 'there',
1 => true,
'column-mapping-config' => ['a', 'b', 'c'],
];
$repository->shouldReceive('getConfiguration')->andReturn($fakeConfig)->once();
$this->be($this->user());
$response = $this->get(route('import.job.download', [$job->key]));
$response->assertStatus(200);
$response->assertExactJson(['column-mapping-config' => [], 'delimiter' => ',', 'hi' => 'there', 1 => true]);
}
/**
* @covers \FireflyIII\Http\Controllers\Import\IndexController
*/

View File

@@ -80,7 +80,7 @@ class JobStatusControllerTest extends TestCase
$job->user_id = $this->user()->id;
$job->key = 'Bfake_job_' . random_int(1, 1000);
$job->status = 'ready_to_run';
$job->provider = 'fake';
$job->provider = 'file';
$job->transactions = [];
$job->file_type = '';
$job->save();