1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* |
7
|
|
|
*/ |
8
|
|
|
class GetInstanceTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* |
12
|
|
|
*/ |
13
|
|
|
public function testUnknownEngineRaisesANotice() |
14
|
|
|
{ |
15
|
|
|
$error_reporting = error_reporting(); |
16
|
|
|
error_reporting(E_ALL); |
17
|
|
|
try { |
18
|
|
|
Engine::__getInstance('this is an unknown format :)'); |
19
|
|
|
} catch (\PHPUnit_Framework_Error $exptected) { |
20
|
|
|
error_reporting($error_reporting); |
21
|
|
|
$this->assertInstanceOf('PHPUnit_Framework_Error', $exptected); |
22
|
|
|
|
23
|
|
|
return; |
24
|
|
|
} |
25
|
|
|
error_reporting($error_reporting); |
26
|
|
|
$this->fail('Did not receive the notice'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @dataProvider enginesProvider |
31
|
|
|
* |
32
|
|
|
* @param string $engineString |
33
|
|
|
* @param string $source |
34
|
|
|
*/ |
35
|
|
|
public function testEngine($engineString, $source) |
36
|
|
|
{ |
37
|
|
|
$engine = @Engine::__getInstance($source); |
38
|
|
|
$this->assertInstanceOf('\\Kingsquare\\Parser\\Banking\\Mt940\\Engine\\'.$engineString, $engine); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @dataProvider enginesProvider |
43
|
|
|
* |
44
|
|
|
* @param string $engineString |
45
|
|
|
* @param string $source |
46
|
|
|
*/ |
47
|
|
|
public function testSingleEngine($engineString, $source) |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
Engine::resetEngines(); |
50
|
|
|
$engine = @Engine::__getInstance($source); |
51
|
|
|
$this->assertInstanceOf('\\Kingsquare\\Parser\\Banking\\Mt940\\Engine\\Unknown', $engine); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function enginesProvider() |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
|
|
['Abn', file_get_contents(__DIR__.'/Abn/sample')], |
61
|
|
|
['Ing', file_get_contents(__DIR__.'/Ing/sample')], |
62
|
|
|
['Rabo', file_get_contents(__DIR__.'/Rabo/sample')], |
63
|
|
|
['Spk', file_get_contents(__DIR__.'/Spk/sample')], |
64
|
|
|
['Triodos', file_get_contents(__DIR__.'/Triodos/sample')], |
65
|
|
|
['Unknown', 'this is an unknown format :)'], |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.