Completed
Push — master ( 3652f2...13727b )
by
unknown
26s queued 10s
created

ParseTest::testParsesAllFoundStatements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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