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
|
|
|
|