1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine\Spk; |
4
|
|
|
|
5
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine\Spk; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
class ParseTest extends \PHPUnit_Framework_TestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Spk |
14
|
|
|
*/ |
15
|
|
|
private $engine = null; |
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$this->engine = new Spk(); |
20
|
|
|
$this->engine->loadString(file_get_contents(__DIR__.'/sample')); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* |
25
|
|
|
*/ |
26
|
|
|
public function testParseStatementBank() |
27
|
|
|
{ |
28
|
|
|
$method = new \ReflectionMethod($this->engine, 'parseStatementBank'); |
29
|
|
|
$method->setAccessible(true); |
30
|
|
|
$this->assertEquals('Spk', $method->invoke($this->engine)); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* |
35
|
|
|
*/ |
36
|
|
|
public function testHasTheRightAmountOfTransactions() |
37
|
|
|
{ |
38
|
|
|
$statements = $this->engine->parse(); |
39
|
|
|
$this->assertSame(4, count($statements)); |
40
|
|
|
$tranactions = []; |
41
|
|
|
foreach ($statements as $statement) { |
42
|
|
|
$tranactions = array_merge($tranactions, $statement->getTransactions()); |
43
|
|
|
} |
44
|
|
|
$this->assertSame(10, count($tranactions)); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
View Code Duplication |
public function testParsesAllFoundStatements() |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
$statements = $this->engine->parse(); |
50
|
|
|
$first = $statements[0]; |
51
|
|
|
$last = end($statements); |
52
|
|
|
$this->assertEquals('17-02-2010', $first->getStartTimestamp('d-m-Y')); |
53
|
|
|
$this->assertEquals('17-02-2010', $first->getEndTimestamp('d-m-Y')); |
54
|
|
|
$this->assertEquals('18-02-2010', $last->getStartTimestamp('d-m-Y')); |
55
|
|
|
$this->assertEquals('18-02-2010', $last->getEndTimestamp('d-m-Y')); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.