mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Basic storage routine works, basic file handling.
This commit is contained in:
@@ -81,7 +81,7 @@ class IndexControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\IndexController
|
||||
*/
|
||||
public function testCreateFakeNoPrereq()
|
||||
public function testCreateFakeNoPrereq(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
@@ -112,18 +112,15 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
// fake prerequisites providers:
|
||||
$fake = $this->mock(FakePrerequisites::class);
|
||||
$file = $this->mock(FilePrerequisites::class);
|
||||
$bunq = $this->mock(BunqPrerequisites::class);
|
||||
$spectre = $this->mock(SpectrePrerequisites::class);
|
||||
|
||||
// call methods:
|
||||
$fake->shouldReceive('setUser')->once();
|
||||
$file->shouldReceive('setUser')->once();
|
||||
$bunq->shouldReceive('setUser')->once();
|
||||
$spectre->shouldReceive('setUser')->once();
|
||||
|
||||
$fake->shouldReceive('isComplete')->once()->andReturn(true);
|
||||
$file->shouldReceive('isComplete')->once()->andReturn(true);
|
||||
$bunq->shouldReceive('isComplete')->once()->andReturn(true);
|
||||
$spectre->shouldReceive('isComplete')->once()->andReturn(true);
|
||||
|
||||
|
@@ -288,7 +288,7 @@ class JobStatusControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.job.start', [$job->key]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['status' => 'NOK', 'message' => 'JobStatusController::start expects state "ready_to_run".']);
|
||||
$response->assertExactJson(['status' => 'NOK', 'message' => 'JobStatusController::start expects status "ready_to_run".']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,26 +322,6 @@ class JobStatusControllerTest extends TestCase
|
||||
$response->assertExactJson(['status' => 'OK', 'message' => 'storage_finished']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\JobStatusController
|
||||
*/
|
||||
public function testStoreInvalidState(): void
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Kfake_job_' . random_int(1, 1000);
|
||||
$job->status = 'some_bad_state';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.job.store', [$job->key]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['status' => 'NOK', 'message' => 'JobStatusController::start expects state "provider_finished".']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\JobStatusController
|
||||
*/
|
||||
@@ -372,4 +352,26 @@ class JobStatusControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['status' => 'NOK', 'message' => 'The import storage routine crashed: Some storage exception.']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\JobStatusController
|
||||
*/
|
||||
public function testStoreInvalidState(): void
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'Kfake_job_' . random_int(1, 1000);
|
||||
$job->status = 'some_bad_state';
|
||||
$job->provider = 'fake';
|
||||
$job->transactions = [];
|
||||
$job->file_type = '';
|
||||
$job->save();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.job.store', [$job->key]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(
|
||||
['status' => 'NOK', 'message' => 'JobStatusController::start expects status "provider_finished" instead of "' . $job->status . '".']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -40,11 +40,11 @@ class BillsTest extends TestCase
|
||||
*/
|
||||
public function testGetMapBasic()
|
||||
{
|
||||
$one = new Bill();
|
||||
$one = new Bill;
|
||||
$one->id = 5;
|
||||
$one->name = 'Something';
|
||||
$one->match = 'hi,bye';
|
||||
$two = new Account;
|
||||
$two = new Bill;
|
||||
$two->id = 9;
|
||||
$two->name = 'Else';
|
||||
$two->match = 'match';
|
||||
@@ -59,8 +59,8 @@ class BillsTest extends TestCase
|
||||
// assert this is what the result looks like:
|
||||
$result = [
|
||||
0 => (string)trans('import.map_do_not_map'),
|
||||
9 => 'Else [match]',
|
||||
5 => 'Something [hi,bye]',
|
||||
9 => 'Else',
|
||||
5 => 'Something',
|
||||
];
|
||||
$this->assertEquals($result, $mapping);
|
||||
}
|
||||
|
Reference in New Issue
Block a user