1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine\Ing; |
4
|
|
|
|
5
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine\Ing; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
class ParseTest extends \PHPUnit_Framework_TestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Ing |
14
|
|
|
*/ |
15
|
|
|
private $engine; |
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$this->engine = new Ing(); |
20
|
|
|
$this->engine->loadString(file_get_contents(__DIR__.'/sample')); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testParseStatementBank() |
24
|
|
|
{ |
25
|
|
|
$method = new \ReflectionMethod($this->engine, 'parseStatementBank'); |
26
|
|
|
$method->setAccessible(true); |
27
|
|
|
$this->assertEquals('ING', $method->invoke($this->engine)); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testParsesAllFoundStatements() |
31
|
|
|
{ |
32
|
|
|
$statements = $this->engine->parse(); |
33
|
|
|
|
34
|
|
|
$this->assertCount(1, $statements); |
35
|
|
|
$first = $statements[0]; |
36
|
|
|
|
37
|
|
|
$this->assertEquals('22-07-2010', $first->getStartTimestamp('d-m-Y')); |
38
|
|
|
$this->assertEquals('23-07-2010', $first->getEndTimestamp('d-m-Y')); |
39
|
|
|
$this->assertEquals(-3.47, $first->getDeltaPrice()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
*/ |
45
|
|
|
public function testSanitizeDescription() |
46
|
|
|
{ |
47
|
|
|
$statements = $this->engine->parse(); |
48
|
|
|
$first = $statements[0]->getTransactions()[0]; |
49
|
|
|
$this->assertEquals('', $first->getDescription()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* |
54
|
|
|
*/ |
55
|
|
|
public function testDescription() |
56
|
|
|
{ |
57
|
|
|
$engine = new Ing(); |
58
|
|
|
$engine->loadString(file_get_contents(__DIR__.'/sampleDescription')); |
59
|
|
|
$transactions = $engine->parse()[0]->getTransactions(); |
60
|
|
|
$this->assertEquals('Direct Debet Descr TOTAAL 345 POSTEN', $transactions[0]->getDescription()); |
61
|
|
|
$this->assertEquals('Direct Debet Descr TOTAAL 1 POST', $transactions[1]->getDescription()); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|