|
1
|
|
|
<?php |
|
2
|
|
|
namespace Adelarcubs\OFXParser; |
|
3
|
|
|
|
|
4
|
|
|
use PHPUnit_Framework_TestCase; |
|
5
|
|
|
use SimpleXMLElement; |
|
6
|
|
|
use Adelarcubs\OFXParser\Ofx; |
|
7
|
|
|
use Adelarcubs\OFXParser\OfxParser; |
|
8
|
|
|
use Adelarcubs\OFXParser\OfxMovement; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* |
|
12
|
|
|
* @author Adelar Tiemann Junior <[email protected]> |
|
13
|
|
|
*/ |
|
14
|
|
|
class OfxParseTest extends PHPUnit_Framework_TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @test |
|
19
|
|
|
* @expectedException Exception |
|
20
|
|
|
*/ |
|
21
|
|
|
public function wrongXmlFormat() |
|
22
|
|
|
{ |
|
23
|
|
|
$ofx = OfxParser::loadOfx('<OFX><root></rot></OFX>'); |
|
24
|
|
|
$this->assertNull($ofx); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @test |
|
29
|
|
|
*/ |
|
30
|
|
View Code Duplication |
public function itau() |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_itau.ofx'); |
|
33
|
|
|
$this->assertInstanceOf(Ofx::class, $ofx); |
|
34
|
|
|
$this->assertInternalType('array', $ofx->jsonSerialize()); |
|
35
|
|
|
|
|
36
|
|
|
$this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements()); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @test |
|
41
|
|
|
*/ |
|
42
|
|
View Code Duplication |
public function santander() |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
$ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_santander.ofx'); |
|
45
|
|
|
$this->assertInstanceOf(Ofx::class, $ofx); |
|
46
|
|
|
$this->assertInternalType('array', $ofx->jsonSerialize()); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements()); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @test |
|
53
|
|
|
*/ |
|
54
|
|
View Code Duplication |
public function caixa() |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
$ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_caixa.ofx'); |
|
57
|
|
|
$this->assertInstanceOf(Ofx::class, $ofx); |
|
58
|
|
|
$this->assertInternalType('array', $ofx->jsonSerialize()); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @test |
|
65
|
|
|
*/ |
|
66
|
|
View Code Duplication |
public function faturaCC() |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
$ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/fatura_cc_1.ofx'); |
|
69
|
|
|
$this->assertInstanceOf(Ofx::class, $ofx); |
|
70
|
|
|
$this->assertInternalType('array', $ofx->jsonSerialize()); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements()); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @test |
|
77
|
|
|
*/ |
|
78
|
|
View Code Duplication |
public function itauIso() |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
$ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_itau_iso.ofx'); |
|
81
|
|
|
$this->assertInstanceOf(Ofx::class, $ofx); |
|
82
|
|
|
$this->assertInternalType('array', $ofx->jsonSerialize()); |
|
83
|
|
|
|
|
84
|
|
|
$this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements()); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
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.