1
|
|
|
<?php |
2
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine\Bunq; |
3
|
|
|
|
4
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine\Bunq; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
*/ |
8
|
|
|
class ParseTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* |
13
|
|
|
* @var Bunq |
14
|
|
|
*/ |
15
|
|
|
private $engine; |
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$this->engine = new Bunq(); |
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('BUNQ', $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('31-01-2019', $first->getStartTimestamp('d-m-Y')); |
38
|
|
|
$this->assertEquals('31-05-2019', $first->getEndTimestamp('d-m-Y')); |
39
|
|
|
$this->assertEquals(26.67, $first->getDeltaPrice()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testParseTransactionEntryTimestamp() |
43
|
|
|
{ |
44
|
|
|
$statements = $this->engine->parse(); |
45
|
|
|
$transactions = reset($statements)->getTransactions(); |
46
|
|
|
// the first has no entryTimestamp |
47
|
|
|
$firstTransaction = reset($transactions); |
48
|
|
|
$this->assertEquals('31-01-2019', $firstTransaction->getEntryTimestamp('d-m-Y')); |
49
|
|
|
|
50
|
|
|
// the last does have an entryTimestamp (custom edited) |
51
|
|
|
$lastTransaction = end($transactions); |
52
|
|
|
$this->assertEquals('24-05-2019', $lastTransaction->getEntryTimestamp('d-m-Y')); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|