mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Update tests.
This commit is contained in:
parent
fb863b0bf2
commit
a5515ac89f
@ -47,15 +47,19 @@ class FileConfiguratorTest extends TestCase
|
||||
public function testConfigureJobInitial()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'initial'];
|
||||
$data = ['some' => 'array'];
|
||||
$job = $this->getJob($config);
|
||||
$config = ['stage' => 'initial'];
|
||||
$data = ['some' => 'array'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
|
||||
// assert that new initial is created:
|
||||
$processor = $this->mock(Initial::class);
|
||||
@ -76,15 +80,18 @@ class FileConfiguratorTest extends TestCase
|
||||
public function testConfigureJobMap()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'map'];
|
||||
$data = ['some' => 'array'];
|
||||
$job = $this->getJob($config);
|
||||
$config = ['stage' => 'map'];
|
||||
$data = ['some' => 'array'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new Roles is created:
|
||||
$processor = $this->mock(Map::class);
|
||||
@ -107,9 +114,6 @@ class FileConfiguratorTest extends TestCase
|
||||
*/
|
||||
public function testConfigureJobNoJob()
|
||||
{
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// config
|
||||
$configurator = new FileConfigurator();
|
||||
$configurator->configureJob([]);
|
||||
@ -124,15 +128,18 @@ class FileConfiguratorTest extends TestCase
|
||||
public function testConfigureJobReady()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'ready'];
|
||||
$data = ['some' => 'array'];
|
||||
$job = $this->getJob($config);
|
||||
$config = ['stage' => 'ready'];
|
||||
$data = ['some' => 'array'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -146,15 +153,18 @@ class FileConfiguratorTest extends TestCase
|
||||
*/
|
||||
public function testConfigureJobRoles()
|
||||
{
|
||||
$config = ['stage' => 'roles'];
|
||||
$data = ['some' => 'array'];
|
||||
$job = $this->getJob($config);
|
||||
$config = ['stage' => 'roles'];
|
||||
$data = ['some' => 'array'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new Roles is created:
|
||||
$processor = $this->mock(Roles::class);
|
||||
@ -175,15 +185,18 @@ class FileConfiguratorTest extends TestCase
|
||||
public function testConfigureJobUploadConfig()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'upload-config'];
|
||||
$data = ['some' => 'array'];
|
||||
$job = $this->getJob($config);
|
||||
$config = ['stage' => 'upload-config'];
|
||||
$data = ['some' => 'array'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new UploadConfig is created:
|
||||
$processor = $this->mock(UploadConfig::class);
|
||||
@ -203,14 +216,17 @@ class FileConfiguratorTest extends TestCase
|
||||
public function testGetNextDataInitial()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'initial'];
|
||||
$job = $this->getJob($config);
|
||||
$config = ['stage' => 'initial'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new Initial is created:
|
||||
$processor = $this->mock(Initial::class);
|
||||
@ -243,6 +259,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'upload-config'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -250,6 +267,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new Initial is created:
|
||||
$processor = $this->mock(UploadConfig::class);
|
||||
@ -271,6 +290,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'ksksjje'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -278,6 +298,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// should throw error
|
||||
$configurator = new FileConfigurator();
|
||||
@ -292,6 +314,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data:
|
||||
$config = ['stage' => 'map'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -299,6 +322,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new Initial is created:
|
||||
$processor = $this->mock(Map::class);
|
||||
@ -320,6 +345,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'ready'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -327,6 +353,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -341,6 +369,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'roles'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -348,6 +377,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// assert that new Initial is created:
|
||||
$processor = $this->mock(Roles::class);
|
||||
@ -367,6 +398,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'initial'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -374,6 +406,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run
|
||||
$configurator = new FileConfigurator();
|
||||
@ -393,6 +427,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'slkds903ms90k'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -400,6 +435,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -414,6 +451,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'map'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -421,6 +459,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -439,7 +479,6 @@ class FileConfiguratorTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewNoJob()
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$configurator = new FileConfigurator();
|
||||
$configurator->getNextView();
|
||||
}
|
||||
@ -453,6 +492,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'ready'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -460,6 +500,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run configx§
|
||||
$configurator = new FileConfigurator();
|
||||
@ -474,6 +516,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'roles'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -481,6 +524,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -498,6 +543,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'upload-config'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -505,6 +551,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -522,6 +570,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'upload-config'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -529,6 +578,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->once();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -559,6 +610,7 @@ class FileConfiguratorTest extends TestCase
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'upload-config'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
@ -566,6 +618,8 @@ class FileConfiguratorTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
@ -576,30 +630,6 @@ class FileConfiguratorTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Configuration\FileConfigurator::isJobConfigured
|
||||
*/
|
||||
public function testIsJobConfiguredTrue()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'ready'];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
$configurator->setJob($job);
|
||||
$result = $configurator->isJobConfigured();
|
||||
|
||||
// test
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should throw a FireflyException when $job is null.
|
||||
*
|
||||
@ -612,6 +642,33 @@ class FileConfiguratorTest extends TestCase
|
||||
$configurator->isJobConfigured();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Configuration\FileConfigurator::isJobConfigured
|
||||
*/
|
||||
public function testIsJobConfiguredTrue()
|
||||
{
|
||||
// data
|
||||
$config = ['stage' => 'ready'];
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
|
||||
// mock repos
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config)->twice();
|
||||
$repository->shouldReceive('setConfiguration')->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->andReturn($extended)->once();
|
||||
$repository->shouldReceive('setExtendedStatus')->once();
|
||||
|
||||
// run config
|
||||
$configurator = new FileConfigurator();
|
||||
$configurator->setJob($job);
|
||||
$result = $configurator->isJobConfigured();
|
||||
|
||||
// test
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
*
|
||||
|
@ -62,21 +62,24 @@ class CsvProcessorTest extends TestCase
|
||||
public function testRunBadRole()
|
||||
{
|
||||
// data
|
||||
$config = [
|
||||
$config = [
|
||||
'column-roles' => [
|
||||
0 => 'bad-role',
|
||||
],
|
||||
];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,"Some description"';
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,"Some description"';
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config);
|
||||
$repository->shouldReceive('uploadFileContents')->withArgs([Mockery::any()])->andReturn($csvFile)->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
//$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
//$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
$repository->shouldReceive('addStepsDone')->twice();
|
||||
|
||||
// mock stuff for this single row:
|
||||
$repository->shouldReceive('countByHash')->once()->withArgs([Mockery::any()])->andReturn(0);
|
||||
$processor = new CsvProcessor();
|
||||
@ -93,17 +96,19 @@ class CsvProcessorTest extends TestCase
|
||||
public function testRunBasic()
|
||||
{
|
||||
// data
|
||||
$config = [];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '';
|
||||
$config = [];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '';
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config);
|
||||
$repository->shouldReceive('uploadFileContents')->withArgs([Mockery::any()])->andReturn($csvFile)->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// $repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
// $repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
$repository->shouldReceive('addStepsDone')->times(3);
|
||||
|
||||
$processor = new CsvProcessor();
|
||||
$processor->setJob($job);
|
||||
@ -127,21 +132,23 @@ class CsvProcessorTest extends TestCase
|
||||
public function testRunExisting()
|
||||
{
|
||||
// data
|
||||
$config = [];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,"Some description"';
|
||||
$config = [];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,"Some description"';
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config);
|
||||
$repository->shouldReceive('uploadFileContents')->withArgs([Mockery::any()])->andReturn($csvFile)->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]); // twice for update errors.
|
||||
$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// $repository->shouldReceive('getExtendedStatus')->once()->andReturn([]); // twice for update errors.
|
||||
// $repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
//$repository->shouldReceive('addStepsDone')->times(3);
|
||||
|
||||
// mock stuff for this single row:
|
||||
$repository->shouldReceive('countByHash')->once()->withArgs([Mockery::any()])->andReturn(1);
|
||||
$repository->shouldReceive('addStepsDone')->once()->withArgs([Mockery::any(), 5]);
|
||||
$repository->shouldReceive('addStepsDone')->times(3)->withArgs([Mockery::any(), 1]);
|
||||
$repository->shouldReceive('addError')->once()->withArgs([Mockery::any(), 0, 'Row #0 has already been imported.']);
|
||||
$processor = new CsvProcessor();
|
||||
$processor->setJob($job);
|
||||
@ -167,22 +174,23 @@ class CsvProcessorTest extends TestCase
|
||||
public function testRunInvalidSpecific()
|
||||
{
|
||||
// data
|
||||
$config = [
|
||||
$config = [
|
||||
'specifics' => ['GoodBankDescription' => 1],
|
||||
];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,descr';
|
||||
$row = explode(',', $csvFile);
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,descr';
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config);
|
||||
$repository->shouldReceive('uploadFileContents')->withArgs([Mockery::any()])->andReturn($csvFile)->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// $repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
// $repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// mock stuff for this single row:
|
||||
$repository->shouldReceive('countByHash')->once()->withArgs([Mockery::any()])->andReturn(0);
|
||||
$repository->shouldReceive('addStepsDone')->times(2)->withArgs([Mockery::any(), 1]);
|
||||
|
||||
// mock specific:
|
||||
$processor = new CsvProcessor();
|
||||
@ -216,20 +224,21 @@ class CsvProcessorTest extends TestCase
|
||||
public function testRunSingle()
|
||||
{
|
||||
// data
|
||||
$config = [];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,"Some description"';
|
||||
$config = [];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,"Some description"';
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config);
|
||||
$repository->shouldReceive('uploadFileContents')->withArgs([Mockery::any()])->andReturn($csvFile)->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// $repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
// $repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// mock stuff for this single row:
|
||||
$repository->shouldReceive('countByHash')->once()->withArgs([Mockery::any()])->andReturn(0);
|
||||
$repository->shouldReceive('addStepsDone')->once()->withArgs([Mockery::any(), 1]);
|
||||
$repository->shouldReceive('addStepsDone')->times(3)->withArgs([Mockery::any(), 1]);
|
||||
$processor = new CsvProcessor();
|
||||
$processor->setJob($job);
|
||||
$processor->run();
|
||||
@ -252,23 +261,24 @@ class CsvProcessorTest extends TestCase
|
||||
public function testRunSpecific()
|
||||
{
|
||||
// data
|
||||
$config = [
|
||||
$config = [
|
||||
'specifics' => ['AbnAmroDescription' => 1],
|
||||
];
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,descr';
|
||||
$row = explode(',', $csvFile);
|
||||
$job = $this->getJob($config);
|
||||
$csvFile = '20170101,-12.34,descr';
|
||||
$row = explode(',', $csvFile);
|
||||
$extended = ['steps' => 0, 'done' => 0];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->withArgs([Mockery::any()])->once();
|
||||
$repository->shouldReceive('getConfiguration')->andReturn($config);
|
||||
$repository->shouldReceive('uploadFileContents')->withArgs([Mockery::any()])->andReturn($csvFile)->once();
|
||||
$repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
$repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// $repository->shouldReceive('getExtendedStatus')->once()->andReturn([]);
|
||||
// $repository->shouldReceive('setExtendedStatus')->once()->andReturn($job);
|
||||
// mock stuff for this single row:
|
||||
$repository->shouldReceive('countByHash')->once()->withArgs([Mockery::any()])->andReturn(0);
|
||||
$repository->shouldReceive('addStepsDone')->once()->withArgs([Mockery::any(), 1]);
|
||||
$repository->shouldReceive('addStepsDone')->times(3)->withArgs([Mockery::any(), 1]);
|
||||
|
||||
// mock specific:
|
||||
$specific = $this->mock(AbnAmroDescription::class);
|
||||
|
Loading…
Reference in New Issue
Block a user