Completed
Push — master ( bd2bbc...380a6c )
by Robin
01:57
created

ParseTest::testParseStatementBank()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
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