Completed
Push — master ( e3ae7a...70d4b0 )
by Robin
15s queued 13s
created

ParseTest::testParseStatementBank()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Kingsquare\Parser\Banking\Mt940\Engine\Asn;
4
5
use Kingsquare\Parser\Banking\Mt940\Engine\Asn;
6
7
class ParseTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var Asn
11
     */
12
    private $engine;
13
14
    protected function setUp()
15
    {
16
        $this->engine = new Asn();
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('ASN', $method->invoke($this->engine));
25
    }
26
27
    public function testParsesAllFoundStatements()
28
    {
29
        $statements = $this->engine->parse();
30
31
        $this->assertCount(7, $statements);
32
        $first = $statements[0];
33
34
        $this->assertEquals('02-01-2020', $first->getStartTimestamp('d-m-Y'));
35
        $this->assertEquals('02-01-2020', $first->getEndTimestamp('d-m-Y'));
36
        $this->assertEquals(2000, $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('02-01-2020', $firstTransaction->getEntryTimestamp('d-m-Y'));
46
47
        // the last does have an entryTimestamp (custom edited)
48
        $lastTransaction = end($transactions);
49
        $this->assertEquals('02-01-2020', $lastTransaction->getEntryTimestamp('d-m-Y'));
50
    }
51
}
52