Completed
Push — master ( 9ec196...c21c38 )
by Alex
11:51
created

OrbitaleCmsExtensionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 35.09 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 4
c 3
b 1
f 1
lcom 0
cbo 4
dl 20
loc 57
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConfiguration() 10 10 1
A testConfigurationSymfony2() 10 10 1
A provideConfiguration() 0 20 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
* This file is part of the OrbitaleCmsBundle package.
5
*
6
* (c) Alexandre Rock Ancelet <[email protected]>
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11
12
namespace Orbitale\Bundle\CmsBundle\Tests\DependencyInjection;
13
14
use Orbitale\Bundle\CmsBundle\Tests\Fixtures\App\Stub\OrbitaleCmsExtensionStub;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\Yaml\Yaml;
17
18
class OrbitaleCmsExtensionTest extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @dataProvider provideConfiguration
22
     *
23
     * @param $config
24
     * @param $expected
25
     */
26 View Code Duplication
    public function testConfiguration($config, $expected)
27
    {
28
        $builder = new ContainerBuilder();
29
30
        $ext = new OrbitaleCmsExtensionStub(true);
31
32
        $ext->load($config, $builder);
33
34
        $this->assertEquals($expected['orbitale_cms'], $builder->getParameter('orbitale_cms.config'));
35
    }
36
37
    /**
38
     * @dataProvider provideConfiguration
39
     *
40
     * @param $config
41
     * @param $expected
42
     */
43 View Code Duplication
    public function testConfigurationSymfony2($config, $expected)
44
    {
45
        $builder = new ContainerBuilder();
46
47
        $ext = new OrbitaleCmsExtensionStub(false);
48
49
        $ext->load($config, $builder);
50
51
        $this->assertEquals($expected['orbitale_cms'], $builder->getParameter('orbitale_cms.config'));
52
    }
53
54
    public function provideConfiguration()
55
    {
56
        $dir = __DIR__.'/../Fixtures/App/extension_test/';
57
58
        $configFiles = glob($dir.'config_*.yml');
59
        $resultFiles = glob($dir.'result_*.yml');
60
61
        sort($configFiles);
62
        sort($resultFiles);
63
64
        $tests = array();
65
66
        foreach ($configFiles as $k => $file) {
67
            $tests[] = array(
68
                Yaml::parse(file_get_contents($file)), Yaml::parse(file_get_contents($resultFiles[$k])),
69
            );
70
        }
71
72
        return $tests;
73
    }
74
}
75