Completed
Push — master ( 13727b...1f8899 )
by
unknown
15s queued 11s
created

ParseTest::testParseTransactionDebitCredit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Kingsquare\Parser\Banking\Mt940\Engine\Penta;
4
5
use Kingsquare\Parser\Banking\Mt940\Engine\Penta;
6
7
/**
8
 */
9
class ParseTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    /**
13
     *
14
     * @var Penta
15
     */
16
    private $engine;
17
18
    protected function setUp()
19
    {
20
        $this->engine = new Penta();
21
        $this->engine->loadString(file_get_contents(__DIR__ . '/sample'));
22
    }
23
24
    public function testParseStatementBank()
25
    {
26
        $method = new \ReflectionMethod($this->engine, 'parseStatementBank');
27
        $method->setAccessible(true);
28
        $this->assertEquals('PENTA', $method->invoke($this->engine));
29
    }
30
31
    public function testParsesAllFoundStatements()
32
    {
33
        $statements = $this->engine->parse();
34
35
        $this->assertCount(1, $statements);
36
        $first = $statements[0];
37
38
        $this->assertEquals('30-09-2020', $first->getStartTimestamp('d-m-Y'));
39
        $this->assertEquals('30-09-2020', $first->getEndTimestamp('d-m-Y'));
40
        $this->assertEquals(10576.30, $first->getDeltaPrice());
41
    }
42
43
    public function testParseTransactionEntryTimestamp()
44
    {
45
        $statements = $this->engine->parse();
46
        $transactions = reset($statements)->getTransactions();
47
        // the first has no entryTimestamp
48
        $firstTransaction = reset($transactions);
49
        $this->assertEquals('02-09-2020', $firstTransaction->getEntryTimestamp('d-m-Y'));
50
51
        // the last does have an entryTimestamp (custom edited)
52
        $lastTransaction = end($transactions);
53
        $this->assertEquals('30-09-2020', $lastTransaction->getEntryTimestamp('d-m-Y'));
54
    }
55
    
56
    public function testParseTransactionDebitCredit()
57
    {
58
        $statements = $this->engine->parse();
59
        $transactions = reset($statements)->getTransactions();
60
        $firstTransaction = reset($transactions);
61
62
        $this->assertEquals('D', $firstTransaction->getDebitCredit());
63
    }
64
    
65
    public function testParseTransactionPrice()
66
    {
67
        $statements = $this->engine->parse();
68
        $transactions = reset($statements)->getTransactions();
69
        $firstTransaction = reset($transactions);
70
71
        $this->assertEquals(20, $firstTransaction->getPrice());
72
    }
73
}
74