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