ParseTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
dl 0
loc 64
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testParsesAllFoundStatements() 0 10 1
A testParseTransactionEntryTimestamp() 0 11 1
A setUp() 0 4 1
A testParseStatementBank() 0 5 1
A testParseTransactionPrice() 0 7 1
A testParseTransactionDebitCredit() 0 7 1
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