Completed
Push — master ( 26e69a...ab0b77 )
by Robin
03:27
created

GetInstanceTest::enginesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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)
0 ignored issues
show
Unused Code introduced by
The parameter $engineString is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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