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 testParseTransactionEntryTimestamp() |
46
|
|
|
{ |
47
|
|
|
$statements = $this->engine->parse(); |
48
|
|
|
$transactions = reset($statements)->getTransactions(); |
49
|
|
|
// the first has no entryTimestamp |
50
|
|
|
$firstTransaction = reset($transactions); |
51
|
|
|
$this->assertEquals(0, $firstTransaction->getEntryTimestamp()); |
52
|
|
|
|
53
|
|
|
// the last does have an entryTimestamp (custom edited) |
54
|
|
|
$lastTransaction = end($transactions); |
55
|
|
|
$this->assertEquals('2010-07-21', $lastTransaction->getEntryTimestamp('Y-m-d')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testParseTransactionDebitCredit() |
59
|
|
|
{ |
60
|
|
|
$statements = $this->engine->parse(); |
61
|
|
|
$transactions = reset($statements)->getTransactions(); |
62
|
|
|
$firstTransaction = reset($transactions); |
63
|
|
|
|
64
|
|
|
$this->assertEquals('C', $firstTransaction->getDebitCredit()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testParseTransactionPrice() |
68
|
|
|
{ |
69
|
|
|
$statements = $this->engine->parse(); |
70
|
|
|
$transactions = reset($statements)->getTransactions(); |
71
|
|
|
$firstTransaction = reset($transactions); |
72
|
|
|
|
73
|
|
|
$this->assertEquals(25.03, $firstTransaction->getPrice()); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|