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

ParseTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
c 1
b 0
f 1
dl 0
loc 43
rs 10
wmc 4

4 Methods

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