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

@@ -53,7 +53,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertFalse($configurator->configurationComplete());
}
@@ -76,7 +76,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertFalse($configurator->configurationComplete());
}
@@ -101,7 +101,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertFalse($configurator->configurationComplete());
}
@@ -129,7 +129,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertFalse($configurator->configurationComplete());
}
@@ -156,7 +156,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertFalse($configurator->configurationComplete());
}
@@ -184,7 +184,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertTrue($configurator->configurationComplete());
}
@@ -211,7 +211,7 @@ class FakeJobConfigurationTest extends TestCase
// should be false:
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertTrue($configurator->configurationComplete());
}
@@ -245,7 +245,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -280,7 +280,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -315,7 +315,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -350,7 +350,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -385,7 +385,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -420,7 +420,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -455,7 +455,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -490,7 +490,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$messages = $configurator->configureJob($data);
$this->assertTrue($messages->has('some_key'));
}
@@ -514,7 +514,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$view = $configurator->getNextView();
$this->assertEquals('import.fake.enter-album', $view);
}
@@ -538,7 +538,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$view = $configurator->getNextView();
$this->assertEquals('import.fake.enter-artist', $view);
}
@@ -562,7 +562,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$view = $configurator->getNextView();
$this->assertEquals('import.fake.apply-rules', $view);
}
@@ -586,7 +586,7 @@ class FakeJobConfigurationTest extends TestCase
// call configuration
$configurator = new FakeJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$view = $configurator->getNextView();
$this->assertEquals('import.fake.enter-song', $view);
}

View File

@@ -59,7 +59,7 @@ class FileJobConfigurationTest extends TestCase
// should be false:
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertFalse($configurator->configurationComplete());
}
@@ -82,7 +82,7 @@ class FileJobConfigurationTest extends TestCase
// should be false:
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$this->assertTrue($configurator->configurationComplete());
}
@@ -107,10 +107,10 @@ class FileJobConfigurationTest extends TestCase
$result = null;
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$handler = $this->mock(ConfigureMappingHandler::class);
$handler->shouldReceive('setJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('setImportJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('configureJob')->withArgs([['c' => 'd']])->andReturn($bag)->once();
try {
@@ -140,10 +140,10 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$handler = $this->mock(ConfigureUploadHandler::class);
$handler->shouldReceive('setJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('setImportJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('getNextData')->andReturn(['a' => 'b'])->withNoArgs()->once();
try {
@@ -173,10 +173,10 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$handler = $this->mock(ConfigureMappingHandler::class);
$handler->shouldReceive('setJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('setImportJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('getNextData')->andReturn(['a' => 'b'])->withNoArgs()->once();
try {
@@ -206,10 +206,10 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$handler = $this->mock(NewFileJobHandler::class);
$handler->shouldReceive('setJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('setImportJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('getNextData')->andReturn(['a' => 'b'])->withNoArgs()->once();
try {
@@ -239,10 +239,10 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
$handler = $this->mock(ConfigureRolesHandler::class);
$handler->shouldReceive('setJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('setImportJob')->once()->withArgs([Mockery::any()]);
$handler->shouldReceive('getNextData')->andReturn(['a' => 'b'])->withNoArgs()->once();
try {
@@ -272,7 +272,7 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
try {
$result = $configurator->getNextView();
} catch (FireflyException $e) {
@@ -300,7 +300,7 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
try {
$result = $configurator->getNextView();
} catch (FireflyException $e) {
@@ -328,7 +328,7 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
try {
$result = $configurator->getNextView();
} catch (FireflyException $e) {
@@ -356,7 +356,7 @@ class FileJobConfigurationTest extends TestCase
$result = 'x';
$configurator = new FileJobConfiguration;
$configurator->setJob($job);
$configurator->setImportJob($job);
try {
$result = $configurator->getNextView();
} catch (FireflyException $e) {

View File

@@ -65,7 +65,7 @@ class FakeRoutineTest extends TestCase
$routine = new FakeRoutine;
$routine->setJob($job);
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {
@@ -98,10 +98,10 @@ class FakeRoutineTest extends TestCase
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
$repository->shouldReceive('setTransactions')->withArgs([Mockery::any(), []])->once();
$handler->shouldReceive('getTransactions')->once()->andReturn([]);
$handler->shouldReceive('setJob')->once();
$handler->shouldReceive('setImportJob')->once();
$routine = new FakeRoutine;
$routine->setJob($job);
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {
@@ -136,7 +136,7 @@ class FakeRoutineTest extends TestCase
$routine = new FakeRoutine;
$routine->setJob($job);
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {

View File

@@ -63,12 +63,12 @@ class FileRoutineTest extends TestCase
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
$repository->shouldReceive('setTransactions')->withArgs([Mockery::any(), ['a' => 'b']])->once();
$repository->shouldReceive('getConfiguration')->withArgs([Mockery::any()])->once()->andReturn([]);
$processor->shouldReceive('setJob')->once();
$processor->shouldReceive('setImportJob')->once();
$processor->shouldReceive('run')->once()->andReturn(['a' => 'b']);
$routine = new FileRoutine;
$routine->setJob($job);
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {

View File

@@ -76,7 +76,7 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('setUser')->once();
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
}
/**
@@ -131,7 +131,7 @@ class ImportArrayStorageTest extends TestCase
->withArgs([Mockery::any(), 'Entry #1 ("' . $transactions[1]['description'] . '") could not be imported. It already exists.']);
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();
@@ -170,7 +170,7 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('setUser')->once();
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();
@@ -214,7 +214,7 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('setUser')->once();
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();
@@ -265,7 +265,7 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('findByHash')->andReturn(null)->once();
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();
@@ -320,7 +320,7 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('findByHash')->andReturn(null)->once();
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();
@@ -393,7 +393,7 @@ class ImportArrayStorageTest extends TestCase
$collector->shouldReceive('getJournals')->andReturn($transferCollection);
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();
@@ -472,7 +472,7 @@ class ImportArrayStorageTest extends TestCase
$collector->shouldReceive('getJournals')->andReturn($transferCollection);
$storage = new ImportArrayStorage;
$storage->setJob($job);
$storage->setImportJob($job);
$result = new Collection;
try {
$result = $storage->store();