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

ParseTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 27
dl 0
loc 61
rs 10
c 1
b 0
f 1
wmc 6

6 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
A testParseTransactionDebitCredit() 0 7 1
A testParseTransactionPrice() 0 7 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
    public function testParseTransactionDebitCredit()
53
    {
54
        $statements = $this->engine->parse();
55
        $transactions = reset($statements)->getTransactions();
56
        $firstTransaction = reset($transactions);
57
58
        $this->assertEquals('D', $firstTransaction->getDebitCredit());
59
    }
60
    
61
    public function testParseTransactionPrice()
62
    {
63
        $statements = $this->engine->parse();
64
        $transactions = reset($statements)->getTransactions();
65
        $firstTransaction = reset($transactions);
66
67
        $this->assertEquals(2000, $firstTransaction->getPrice());
68
    }
69
}
70