Code consistency and new tests.

This commit is contained in:
James Cole
2018-05-12 15:50:01 +02:00
parent a47da92d81
commit 5bf520b6ed
35 changed files with 1262 additions and 1157 deletions

View File

@@ -74,7 +74,7 @@ class ConfigureMappingHandlerTest extends TestCase
];
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$result = $handler->applySpecifics($config, []);
$this->assertEquals($expected, $result);
@@ -139,7 +139,7 @@ class ConfigureMappingHandlerTest extends TestCase
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$handler->configureJob($input);
}
@@ -197,7 +197,7 @@ class ConfigureMappingHandlerTest extends TestCase
];
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$result = $handler->doColumnConfig($input);
} catch (FireflyException $e) {
@@ -231,7 +231,7 @@ class ConfigureMappingHandlerTest extends TestCase
];
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
foreach ($combinations as $info) {
$this->assertEquals($info['expected'], $handler->doMapOfColumn($info['role'], $info['requested']));
}
@@ -298,7 +298,7 @@ class ConfigureMappingHandlerTest extends TestCase
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$result = $handler->getNextData();
} catch (FireflyException $e) {
@@ -340,7 +340,7 @@ class ConfigureMappingHandlerTest extends TestCase
];
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
foreach ($combinations as $info) {
$this->assertEquals($info['expected'], $handler->getPreProcessorName($info['role']));
}
@@ -386,7 +386,7 @@ class ConfigureMappingHandlerTest extends TestCase
$attachments->shouldReceive('getAttachmentContent')->withArgs([Mockery::any()])->andReturn($fileContent);
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$reader = $handler->getReader();
} catch (Exception $e) {
@@ -449,7 +449,7 @@ class ConfigureMappingHandlerTest extends TestCase
$job->save();
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$result = [];
try {
$result = $handler->getValuesForMapping($reader, $config, $columnConfig);
@@ -478,7 +478,7 @@ class ConfigureMappingHandlerTest extends TestCase
$job->save();
$handler = new ConfigureMappingHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$keys = array_keys(config('csv.import_roles'));
foreach ($keys as $key) {
$this->assertEquals($key, $handler->sanitizeColumnName($key));

View File

@@ -159,7 +159,7 @@ class ConfigureRolesHandlerTest extends TestCase
$repository->shouldReceive('setConfiguration')->once()->withArgs([Mockery::any(), $expected]);
$handler = new ConfigureRolesHandler();
$handler->setJob($job);
$handler->setImportJob($job);
$handler->configureJob($data);
}
@@ -207,7 +207,7 @@ class ConfigureRolesHandlerTest extends TestCase
$file = "one,two,,three\nfour,five,,six\none,three,X,three";
$reader = Reader::createFromString($file);
$handler = new ConfigureRolesHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$handler->getExamplesFromFile($reader, $job->configuration);
} catch (Exception $e) {
@@ -321,7 +321,7 @@ class ConfigureRolesHandlerTest extends TestCase
];
$handler = new ConfigureRolesHandler();
$handler->setJob($job);
$handler->setImportJob($job);
try {
$result = $handler->getNextData();
} catch (Exception $e) {
@@ -373,7 +373,7 @@ class ConfigureRolesHandlerTest extends TestCase
$attachments->shouldReceive('getAttachmentContent')->withArgs([Mockery::any()])->andReturn($fileContent);
$handler = new ConfigureRolesHandler();
$handler->setJob($job);
$handler->setImportJob($job);
try {
$reader = $handler->getReader();
} catch (Exception $e) {
@@ -518,7 +518,7 @@ class ConfigureRolesHandlerTest extends TestCase
->withArgs([Mockery::any(), ['column-count' => 0]]);
$handler = new ConfigureRolesHandler();
$handler->setJob($job);
$handler->setImportJob($job);
$handler->saveColumCount();
}

View File

@@ -80,7 +80,7 @@ class ConfigureUploadHandlerTest extends TestCase
$repository->shouldReceive('setStage')->once()->withArgs([Mockery::any(), 'roles']);
$handler = new ConfigureUploadHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$result = $handler->configureJob($data);
$this->assertCount(0, $result);
}
@@ -127,7 +127,7 @@ class ConfigureUploadHandlerTest extends TestCase
$repository->shouldReceive('setConfiguration')->once()->withArgs([Mockery::any(), $expectedConfig]);
$handler = new ConfigureUploadHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$result = $handler->configureJob($data);
$this->assertCount(1, $result);
$this->assertEquals('You have selected an invalid account to import into.', $result->get('account')[0]);
@@ -153,7 +153,7 @@ class ConfigureUploadHandlerTest extends TestCase
$repository->shouldReceive('setConfiguration')->once()->withArgs([Mockery::any(), ['date-format' => 'Ymd']]);
$handler = new ConfigureUploadHandler;
$handler->setJob($job);
$handler->setImportJob($job);
$result = $handler->getNextData();
$expected = [
'accounts' => [],

View File

@@ -85,7 +85,7 @@ class NewFileJobHandlerTest extends TestCase
];
$handler = new NewFileJobHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$messages = $handler->configureJob($data);
} catch (FireflyException $e) {
@@ -139,7 +139,7 @@ class NewFileJobHandlerTest extends TestCase
];
$handler = new NewFileJobHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$messages = $handler->configureJob($data);
} catch (FireflyException $e) {
@@ -190,7 +190,7 @@ class NewFileJobHandlerTest extends TestCase
$repository->shouldReceive('setConfiguration')->withArgs([Mockery::any(), ['a' => 'b']])->once();
$handler = new NewFileJobHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$handler->storeConfiguration();
@@ -237,7 +237,7 @@ class NewFileJobHandlerTest extends TestCase
$handler = new NewFileJobHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$result = $handler->validateAttachments();
@@ -288,7 +288,7 @@ class NewFileJobHandlerTest extends TestCase
$handler = new NewFileJobHandler;
$handler->setJob($job);
$handler->setImportJob($job);
try {
$result = $handler->validateAttachments();