Files
firefly-iii/tests/Unit/Import/Specifics/IngDescriptionTest.php

154 lines
4.3 KiB
PHP
Raw Normal View History

<?php
/**
* IngDescriptionTest.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Import\Specifics;
use FireflyIII\Import\Specifics\IngDescription;
use Log;
use Tests\TestCase;
/**
* Class IngDescriptionTest
2019-08-17 10:48:28 +02:00
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class IngDescriptionTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
2019-04-09 20:05:20 +02:00
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
2018-08-06 19:14:30 +02:00
* Test changes to BA row.
*
* Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
2018-08-06 19:14:30 +02:00
public function testRunBABasic(): void
{
2018-08-06 19:14:30 +02:00
$row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
2018-08-06 19:14:30 +02:00
$this->assertEquals('XX XX', $result[8]);
}
/**
2018-08-06 19:14:30 +02:00
* Empty description? Use "tegenrekening".
* Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
2018-08-06 19:14:30 +02:00
public function testRunEmptyDescr(): void
{
2018-08-06 19:14:30 +02:00
$row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
2018-08-06 19:14:30 +02:00
$this->assertEquals('Bla bla', $result[3]);
}
/**
2018-08-06 19:14:30 +02:00
* See if the description is removed
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
2018-08-06 19:14:30 +02:00
public function testRunGTRemoveDescr(): void
{
$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];
$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
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
2018-08-06 19:14:30 +02:00
public function testRunGTRemoveIban(): void
{
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];
$parser = new IngDescription;
$result = $parser->run($row);
2018-08-06 19:14:30 +02:00
$this->assertEquals('Should be removed', $result[8]);
}
/**
2018-08-06 19:14:30 +02:00
* Try if the IBAN is removed in IC transactions
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
2018-08-06 19:14:30 +02:00
public function testRunICRemoveIban(): void
{
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];
$parser = new IngDescription;
$result = $parser->run($row);
2018-08-06 19:14:30 +02:00
$this->assertEquals('Should be removed', $result[8]);
}
/**
2018-08-06 19:14:30 +02:00
* Try if the IBAN is removed in OV transactions
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
2018-08-06 19:14:30 +02:00
public function testRunOVRemoveIban(): void
{
$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];
$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
}