Passed
Pull Request — master (#65)
by Robin
02:59 queued 01:31
created

ParseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testParsesAllFoundStatements() 0 10 1
A setUp() 0 4 1
A testParseStatementBank() 0 5 1
A testSanitizeDescription() 0 5 1
A testDescription() 0 7 1
1
<?php
2
3
namespace Kingsquare\Parser\Banking\Mt940\Engine\Ing;
4
5
use Kingsquare\Parser\Banking\Mt940\Engine\Ing;
6
7
/**
8
 *
9
 */
10
class ParseTest extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * @var Ing
14
     */
15
    private $engine;
16
17
    protected function setUp()
18
    {
19
        $this->engine = new Ing();
20
        $this->engine->loadString(file_get_contents(__DIR__.'/sample'));
21
    }
22
23
    public function testParseStatementBank()
24
    {
25
        $method = new \ReflectionMethod($this->engine, 'parseStatementBank');
26
        $method->setAccessible(true);
27
        $this->assertEquals('ING', $method->invoke($this->engine));
28
    }
29
30
    public function testParsesAllFoundStatements()
31
    {
32
        $statements = $this->engine->parse();
33
34
        $this->assertCount(1, $statements);
35
        $first = $statements[0];
36
37
        $this->assertEquals('22-07-2010', $first->getStartTimestamp('d-m-Y'));
38
        $this->assertEquals('23-07-2010', $first->getEndTimestamp('d-m-Y'));
39
        $this->assertEquals(-3.47, $first->getDeltaPrice());
40
    }
41
42
    /**
43
     *
44
     */
45
    public function testSanitizeDescription()
46
    {
47
        $statements = $this->engine->parse();
48
        $first = $statements[0]->getTransactions()[0];
49
        $this->assertEquals('', $first->getDescription());
50
    }
51
52
    /**
53
     *
54
     */
55
    public function testDescription()
56
    {
57
        $engine = new Ing();
58
        $engine->loadString(file_get_contents(__DIR__.'/sampleDescription'));
59
        $transactions = $engine->parse()[0]->getTransactions();
60
        $this->assertEquals('Direct Debet Descr TOTAAL        345 POSTEN', $transactions[0]->getDescription());
61
        $this->assertEquals('Direct Debet Descr TOTAAL 1 POST', $transactions[1]->getDescription());
62
    }
63
}
64