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

testConfigurationSymfony2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
rs 9.4286
cc 1
eloc 5
nc 1
nop 2
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