Completed
Push — master ( cb46a0...974133 )
by Marc
04:34
created

InigoRendererTest::runSuiteProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 13
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace Kaloa\Tests;
4
5
use Kaloa\Renderer\Config;
6
use Kaloa\Renderer\Factory;
7
use PHPUnit_Framework_TestCase;
8
9
/**
10
 *
11
 */
12
class InigoRendererTest extends PHPUnit_Framework_TestCase
13
{
14
    /**
15
     *
16
     */
17
    public function testIntegrity()
18
    {
19
        // Environment
20
        $contentToRender = file_get_contents(__DIR__ . '/examples/inigo/klangbilder.txt');
21
        $resourceBasePath = __DIR__ . '/examples/inigo/res';
22
        $filter = 'inigo';
23
24
        $config = new Config($resourceBasePath);
25
26
        $renderer = Factory::createRenderer($filter, $config);
27
28
        $output = $renderer->render($contentToRender);
29
30
        $expected = file_get_contents(__DIR__ . '/examples/inigo/klangbilder.expected');
31
32
        $expected = str_replace('__RESOURCE_BASE_PATH__', $config->getResourceBasePath(), $expected);
33
34
        $this->assertEquals($expected, $output);
35
    }
36
37 View Code Duplication
    public function runSuiteProvider()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $sets = array();
40
41
        foreach (glob(__DIR__ . '/examples/inigo/*.txt') as $file) {
42
            $sets[] = array(
43
                realpath($file),
44
                realpath(substr($file, 0, -4) . '.expected')
45
            );
46
        }
47
48
        return $sets;
49
    }
50
51
    /**
52
     * @dataProvider runSuiteProvider
53
     */
54
    public function testRunSuite($fileInput, $fileExpected)
55
    {
56
        $resourceBasePath = __DIR__ . '/examples/inigo/res';
57
58
        $config = new Config($resourceBasePath);
59
60
        $renderer = Factory::createRenderer('inigo', $config);
61
62
        $output   = $renderer->render(file_get_contents($fileInput));
63
        $expected = file_get_contents($fileExpected);
64
65
        $expected = str_replace('__RESOURCE_BASE_PATH__', $config->getResourceBasePath(), $expected);
66
67
        $this->assertEquals($expected, $output);
68
    }
69
}
70