2018-05-05 11:03:10 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* IngDescriptionTest.php
|
|
|
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This file is part of Firefly III.
|
|
|
|
*
|
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Tests\Unit\Import\Specifics;
|
|
|
|
|
|
|
|
|
|
|
|
use FireflyIII\Import\Specifics\IngDescription;
|
2018-09-04 09:52:19 +02:00
|
|
|
use Log;
|
2019-04-09 15:32:48 +02:00
|
|
|
use Tests\TestCase;
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class IngDescriptionTest
|
|
|
|
*/
|
|
|
|
class IngDescriptionTest extends TestCase
|
|
|
|
{
|
2018-09-04 09:52:19 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
Log::info(sprintf('Now in %s.', \get_class($this)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-05 11:03:10 +02:00
|
|
|
/**
|
2018-08-06 19:14:30 +02:00
|
|
|
* Test changes to BA row.
|
|
|
|
*
|
|
|
|
* Remove specific fields.
|
2018-05-05 11:03:10 +02:00
|
|
|
*
|
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
2018-08-06 19:14:30 +02:00
|
|
|
public function testRunBABasic(): void
|
2018-05-05 11:03:10 +02:00
|
|
|
{
|
2018-08-06 19:14:30 +02:00
|
|
|
$row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
2018-08-06 19:14:30 +02:00
|
|
|
$this->assertEquals('XX XX', $result[8]);
|
2018-05-05 11:03:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-06 19:14:30 +02:00
|
|
|
* Empty description? Use "tegenrekening".
|
|
|
|
* Remove specific fields.
|
2018-05-05 11:03:10 +02:00
|
|
|
*
|
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
2018-08-06 19:14:30 +02:00
|
|
|
public function testRunEmptyDescr(): void
|
2018-05-05 11:03:10 +02:00
|
|
|
{
|
2018-08-06 19:14:30 +02:00
|
|
|
$row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
2018-08-06 19:14:30 +02:00
|
|
|
$this->assertEquals('Bla bla', $result[3]);
|
2018-05-05 11:03:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-06 19:14:30 +02:00
|
|
|
* See if the description is removed
|
2018-05-05 11:03:10 +02:00
|
|
|
*
|
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
2018-08-06 19:14:30 +02:00
|
|
|
public function testRunGTRemoveDescr(): void
|
2018-05-05 11:03:10 +02:00
|
|
|
{
|
|
|
|
$iban = 'NL66INGB0665877351';
|
2018-08-06 19:14:30 +02:00
|
|
|
$row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
|
|
|
$this->assertEquals('Should be removed', $result[8]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-06 19:14:30 +02:00
|
|
|
* Try if the IBAN is removed in GT transactions
|
2018-05-05 11:03:10 +02:00
|
|
|
*
|
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
2018-08-06 19:14:30 +02:00
|
|
|
public function testRunGTRemoveIban(): void
|
2018-05-05 11:03:10 +02:00
|
|
|
{
|
2018-08-06 19:14:30 +02:00
|
|
|
$iban = 'NL66INGB0665877351';
|
|
|
|
$row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
2018-08-06 19:14:30 +02:00
|
|
|
$this->assertEquals('Should be removed', $result[8]);
|
2018-05-05 11:03:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-06 19:14:30 +02:00
|
|
|
* Try if the IBAN is removed in IC transactions
|
2018-05-05 11:03:10 +02:00
|
|
|
*
|
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
2018-08-06 19:14:30 +02:00
|
|
|
public function testRunICRemoveIban(): void
|
2018-05-05 11:03:10 +02:00
|
|
|
{
|
2018-08-06 19:14:30 +02:00
|
|
|
$iban = 'NL66INGB0665877351';
|
|
|
|
$row = [0, 1, 2, $iban, 'IC', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
2018-08-06 19:14:30 +02:00
|
|
|
$this->assertEquals('Should be removed', $result[8]);
|
2018-05-05 11:03:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-06 19:14:30 +02:00
|
|
|
* Try if the IBAN is removed in OV transactions
|
|
|
|
*
|
2018-05-05 11:03:10 +02:00
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
2018-08-06 19:14:30 +02:00
|
|
|
public function testRunOVRemoveIban(): void
|
2018-05-05 11:03:10 +02:00
|
|
|
{
|
|
|
|
$iban = 'NL66INGB0665877351';
|
2018-08-06 19:14:30 +02:00
|
|
|
$row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
|
2018-05-05 11:03:10 +02:00
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
|
|
|
$this->assertEquals('Should be removed', $result[8]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Import\Specifics\IngDescription
|
|
|
|
*/
|
|
|
|
public function testRunShortArray(): void
|
|
|
|
{
|
|
|
|
$row = [0, 1, 2, 3];
|
|
|
|
|
|
|
|
$parser = new IngDescription;
|
|
|
|
$result = $parser->run($row);
|
|
|
|
|
|
|
|
$this->assertEquals($row, $result);
|
|
|
|
}
|
|
|
|
|
2018-05-05 16:51:32 +02:00
|
|
|
}
|