GetInstanceTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 23
c 2
b 0
f 0
dl 0
loc 58
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testSingleEngine() 0 5 1
A testUnknownEngineRaisesANotice() 0 14 2
A enginesProvider() 0 9 1
A testEngine() 0 4 1
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)
0 ignored issues
show
Unused Code introduced by
The parameter $engineString is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

49
    public function testSingleEngine(/** @scrutinizer ignore-unused */ $engineString, $source)

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

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