Passed
Pull Request — master (#76)
by
unknown
02:09
created

ParseTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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