1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine\Knab; |
4
|
|
|
|
5
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine\Knab; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
class ParseTest extends \PHPUnit_Framework_TestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Knab |
14
|
|
|
*/ |
15
|
|
|
private $engine; |
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$this->engine = new Knab(); |
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('KNAB', $method->invoke($this->engine)); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testParsesAllFoundStatements() |
31
|
|
|
{ |
32
|
|
|
$statements = $this->engine->parse(); |
33
|
|
|
|
34
|
|
|
$this->assertCount(1, $statements); |
35
|
|
|
$this->assertEquals('03-12-2015', $statements[0]->getStartTimestamp('d-m-Y')); |
36
|
|
|
$this->assertEquals('03-12-2015', $statements[0]->getStartTimestamp('d-m-Y')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testCorrectHandlingOfVariousStatementPricing() |
40
|
|
|
{ |
41
|
|
|
$statements = $this->engine->parse(); |
42
|
|
|
$this->assertEquals(1000.21, $statements[0]->getStartPrice()); |
43
|
|
|
$this->assertEquals(945.21, $statements[0]->getEndPrice()); |
44
|
|
|
$this->assertEquals(55, $statements[0]->getDeltaPrice()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testUnStructuredMt940() { |
48
|
|
|
$statements = $this->engine->parse(); |
49
|
|
|
$structuredTransaction = $statements[0]->getTransactions()[1]; |
50
|
|
|
$this->assertEquals('NL52RABO0326203011', $structuredTransaction->getAccount()); |
51
|
|
|
$this->assertEquals('SOME NAME', $structuredTransaction->getAccountName()); |
52
|
|
|
$this->assertEquals('61385002542767281000000000000000000 6676341986995664 TEST PURCHAS567890', $structuredTransaction->getDescription()); |
53
|
|
|
|
54
|
|
|
$structuredTransaction = $statements[0]->getTransactions()[3]; |
55
|
|
|
$this->assertEquals('', $structuredTransaction->getAccount()); |
56
|
|
|
$this->assertEquals('POS', $structuredTransaction->getAccountName()); |
57
|
|
|
$this->assertEquals('03-12-2015 16:04 PAS: 1122', $structuredTransaction->getDescription()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testStructuredMt940() { |
61
|
|
|
$statements = $this->engine->parse(); |
62
|
|
|
$structuredTransaction = $statements[0]->getTransactions()[4]; |
63
|
|
|
$this->assertEquals('437015300', $structuredTransaction->getAccount()); |
64
|
|
|
$this->assertEquals('ACHMEA SCHADEVERZEKERINGEN N.V.', $structuredTransaction->getAccountName()); |
65
|
|
|
$this->assertEquals('EERSTE MAAND, MAART VERZEKERING 5002100023 310160', $structuredTransaction->getDescription()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
public function testStartPrice() { |
70
|
|
|
$this->engine->loadString(file_get_contents(__DIR__.'/sample')); |
71
|
|
|
$statements = $this->engine->parse(); |
72
|
|
|
$start_price_m = $statements[0]->getStartPrice(); |
73
|
|
|
$this->assertSame(1000.21 , $start_price_m); |
74
|
|
|
|
75
|
|
|
$this->engine->loadString(file_get_contents(__DIR__.'/sample2')); |
76
|
|
|
$statements = $this->engine->parse(); |
77
|
|
|
$start_price_f = $statements[0]->getStartPrice(); |
78
|
|
|
$this->assertSame(12490.07 , $start_price_f); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function testEndPrice() { |
82
|
|
|
$this->engine->loadString(file_get_contents(__DIR__.'/sample')); |
83
|
|
|
$statements = $this->engine->parse(); |
84
|
|
|
$price_m = $statements[0]->getEndPrice(); |
85
|
|
|
$this->assertSame(945.21 , $price_m); |
86
|
|
|
|
87
|
|
|
$this->engine->loadString(file_get_contents(__DIR__.'/sample2')); |
88
|
|
|
$statements = $this->engine->parse(); |
89
|
|
|
$price_f = $statements[0]->getEndPrice(); |
90
|
|
|
$this->assertSame(13057.49 , $price_f); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|