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

GetInstanceTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 5
c 5
b 0
f 1
lcom 1
cbo 2
dl 0
loc 61
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testUnknownEngineRaisesANotice() 0 15 2
A testEngine() 0 5 1
A testSingleEngine() 0 6 1
A enginesProvider() 0 11 1
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