BassterLegacyBridgeExtensionTest::setLegacyPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Basster\LegacyBridgeBundle\Tests\DependencyInjection;
4
5
use Basster\LegacyBridgeBundle\DependencyInjection\BassterLegacyBridgeExtension;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
8
9
class BassterLegacyBridgeExtensionTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @test
13
     * @dataProvider provideConfigs
14
     */
15
    public function setLegacyPath(
16
      array $config,
17
      $path,
18
      $prepend = null,
19
      $append = null
20
    ) {
21
        $bag = new ParameterBag();
22
23
        $extension = new BassterLegacyBridgeExtension();
24
        $extension->load($config, new ContainerBuilder($bag));
25
26
        self::assertEquals($path,
27
                           $bag->get('basster_legacy_bridge.legacy_path'));
28
        self::assertEquals($prepend,
29
                           $bag->get('basster_legacy_bridge.prepend_script'));
30
        self::assertEquals($append,
31
                           $bag->get('basster_legacy_bridge.append_script'));
32
    }
33
34
    public function provideConfigs()
35
    {
36
        $pathOnly = array(
37
          'basster_legacy_bridge' => array(
38
            'legacy_path' => __DIR__,
39
          ),
40
        );
41
42
        $prependOnly                                            = $pathOnly;
43
        $prependOnly['basster_legacy_bridge']['prepend_script'] = __FILE__;
44
45
        $appendOnly                                           = $pathOnly;
46
        $appendOnly['basster_legacy_bridge']['append_script'] = __FILE__;
47
48
        $all                                            = $pathOnly;
49
        $all['basster_legacy_bridge']['append_script']  = __FILE__;
50
        $all['basster_legacy_bridge']['prepend_script'] = __FILE__;
51
52
        return array(
53
          'path-only'         => array($pathOnly, __DIR__, null, null),
54
          'with-prepend-only' => array($prependOnly, __DIR__, __FILE__, null),
55
          'with-append-only'  => array($appendOnly, __DIR__, null, __FILE__),
56
          'all'               => array($all, __DIR__, __FILE__, __FILE__),
57
        );
58
    }
59
}
60