Code cleanup and realign.

This commit is contained in:
James Cole
2018-08-06 19:14:30 +02:00
parent f7eef25fed
commit 5908c0ce8c
188 changed files with 1019 additions and 1031 deletions

View File

@@ -169,7 +169,7 @@ class AmountCreditTest extends TestCase
foreach ($values as $value => $expected) {
$converter = new AmountCredit;
$result = $converter->convert($value);
//$this->assertEquals($expected, $result, sprintf('The original value was %s, expected was %s', $value, $expected));
//$this->assertEquals($expected, $result, sprintf('The original value was %s, expected was %s', $value, $expected));
}
}

View File

@@ -28,8 +28,8 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Routine\SpectreRoutine;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageAuthenticatedHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
use Mockery;
use Tests\TestCase;
@@ -39,37 +39,6 @@ use Tests\TestCase;
*/
class SpectreRoutineTest extends TestCase
{
/**
* @covers \FireflyIII\Import\Routine\SpectreRoutine
*/
public function testRunDoAuthenticate(): void
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR1A' . random_int(1, 10000);
$job->status = 'ready_to_run';
$job->stage = 'do-authenticate';
$job->provider = 'spectre';
$job->file_type = '';
$job->configuration = [];
$job->save();
// mock handler and repository
$repository = $this->mock(ImportJobRepositoryInterface::class);
// mock calls for repository
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
$routine = new SpectreRoutine;
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
/**
* @covers \FireflyIII\Import\Routine\SpectreRoutine
*/
@@ -108,6 +77,37 @@ class SpectreRoutineTest extends TestCase
}
}
/**
* @covers \FireflyIII\Import\Routine\SpectreRoutine
*/
public function testRunDoAuthenticate(): void
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR1A' . random_int(1, 10000);
$job->status = 'ready_to_run';
$job->stage = 'do-authenticate';
$job->provider = 'spectre';
$job->file_type = '';
$job->configuration = [];
$job->save();
// mock handler and repository
$repository = $this->mock(ImportJobRepositoryInterface::class);
// mock calls for repository
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
$routine = new SpectreRoutine;
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
/**
* @covers \FireflyIII\Import\Routine\SpectreRoutine
*/

View File

@@ -112,7 +112,9 @@ class AbnAmroDescriptionTest extends TestCase
*/
public function testSepaBasic(): void
{
$row = [0, 1, 2, 3, 4, 5, 6, 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238', '',''];
$row = [0, 1, 2, 3, 4, 5, 6,
'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238',
'', ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals('1232138 1232131233 412321 iBOOD.com iBOOD.com B.V.', $result[7]);
@@ -127,7 +129,9 @@ class AbnAmroDescriptionTest extends TestCase
*/
public function testSepaBasicNoDescription(): void
{
$row = [0, 1, 2, 3, 4, 5, 6, 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: Kenmerk: 12-12-2014 21:03 002000 0213123238', '',''];
$row = [0, 1, 2, 3, 4, 5, 6,
'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: Kenmerk: 12-12-2014 21:03 002000 0213123238',
'', ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals(' PLAIN: SEPA iDEAL - Silver Ocean B.V. (12-12-2014)', $result[7]);
@@ -140,23 +144,27 @@ class AbnAmroDescriptionTest extends TestCase
*
* @covers \FireflyIII\Import\Specifics\AbnAmroDescription
*/
public function testTRTPBasic(): void {
public function testTRTPBasic(): void
{
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED', '',''];
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED', '',
''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals('Nullijn', $result[7]);
$this->assertEquals('baasd dsdsT CJ', $result[8]);
$this->assertEquals('NL23ABNA0000000000', $result[9]);
}
/**
* Basic TRTP data with empty description
*
* @covers \FireflyIII\Import\Specifics\AbnAmroDescription
*/
public function testTRTPEmptyDescr(): void {
public function testTRTPEmptyDescr(): void
{
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI//EREF/NOTPROVIDED', '',''];
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI//EREF/NOTPROVIDED', '', ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals('SEPA OVERBOEKING - (NOTPROVIDED)', $result[7]);

View File

@@ -32,6 +32,52 @@ use Tests\TestCase;
*/
class IngDescriptionTest extends TestCase
{
/**
* Test changes to BA row.
*
* Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunBABasic(): void
{
$row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
$this->assertEquals('XX XX', $result[8]);
}
/**
* Empty description? Use "tegenrekening".
* Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunEmptyDescr(): void
{
$row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
$this->assertEquals('Bla bla', $result[3]);
}
/**
* See if the description is removed
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunGTRemoveDescr(): void
{
$iban = 'NL66INGB0665877351';
$row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
$this->assertEquals('Should be removed', $result[8]);
}
/**
* Try if the IBAN is removed in GT transactions
*
@@ -47,21 +93,6 @@ class IngDescriptionTest extends TestCase
$this->assertEquals('Should be removed', $result[8]);
}
/**
* Try if the IBAN is removed in OV transactions
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunOVRemoveIban(): void
{
$iban = 'NL66INGB0665877351';
$row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
$this->assertEquals('Should be removed', $result[8]);
}
/**
* Try if the IBAN is removed in IC transactions
*
@@ -78,44 +109,14 @@ class IngDescriptionTest extends TestCase
}
/**
* Empty description? Use "tegenrekening".
* Remove specific fields.
* Try if the IBAN is removed in OV transactions
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunEmptyDescr(): void
{
$row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
$this->assertEquals('Bla bla', $result[3]);
}
/**
* Test changes to BA row.
*
* Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunBABasic(): void
{
$row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
$this->assertEquals('XX XX', $result[8]);
}
/**
* See if the description is removed
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
public function testRunGTRemoveDescr(): void
public function testRunOVRemoveIban(): void
{
$iban = 'NL66INGB0665877351';
$row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
$row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);

View File

@@ -36,20 +36,9 @@ class PresidentsChoiceTest extends TestCase
/**
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
*/
public function testRunBasic():void {
$row = [''];
$parser = new PresidentsChoice;
$result = $parser->run($row);
$this->assertEquals($row, $result);
}
/**
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
*/
public function testRunAmount():void {
$row = ['','Descr','12.34','',''];
public function testRunAmount(): void
{
$row = ['', 'Descr', '12.34', '', ''];
$parser = new PresidentsChoice;
$result = $parser->run($row);
@@ -58,4 +47,17 @@ class PresidentsChoiceTest extends TestCase
}
/**
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
*/
public function testRunBasic(): void
{
$row = [''];
$parser = new PresidentsChoice;
$result = $parser->run($row);
$this->assertEquals($row, $result);
}
}

View File

@@ -155,8 +155,6 @@ class ImportArrayStorageTest extends TestCase
$collector->shouldReceive('addFilter')->andReturnSelf();
$storage = new ImportArrayStorage;
$storage->setImportJob($job);
$result = new Collection;
@@ -409,7 +407,6 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('findByHash')->andReturn(null)->times(2);
$storage = new ImportArrayStorage;
$storage->setImportJob($job);
$result = new Collection;