Completed
Push — master ( ea4e5e...1a7580 )
by Zbigniew
02:25
created

FixtureZibiosWrikeExtensionTestCase::testBaseConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the WrikeBundle package.
4
 *
5
 * (c) Zbigniew Ślązak
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zibios\Bundle\WrikeBundle\Tests\DependencyInjection\Fixtures;
12
13
use Zibios\Bundle\WrikeBundle\DependencyInjection\ZibiosWrikeExtension;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Zibios\Bundle\WrikeBundle\Tests\TestCase;
16
17
/**
18
 * Fixture ZibiosWrikeExtension Test Case
19
 */
20
abstract class FixtureZibiosWrikeExtensionTestCase extends TestCase
21
{
22
    public function testEmptyConfig()
23
    {
24
        $container = $this->getContainer('empty');
25
26
        self::assertFalse($container->hasParameter('zibios_wrike'), json_encode($container->getParameterBag()));
27
    }
28
29
    public function testDefaultConfig()
30
    {
31
        $container = $this->getContainer('default');
32
33
        $expectedConfiguration = [];
34
        self::assertTrue($container->hasParameter('zibios_wrike'), json_encode($container->getParameterBag()));
35
        self::assertEquals($expectedConfiguration, $container->getParameter('zibios_wrike'));
36
    }
37
38
    public function testBaseConfig()
39
    {
40
        $container = $this->getContainer('base');
41
42
        $expectedConfiguration = [
43
            'permanent_tokens' => [
44
                'tokens' => [
45
                    'first' => 'firstToken',
46
                    'second' => 'secondToken',
47
                ],
48
                'default_token' => 'first',
49
            ],
50
            'api_url' => 'http://urlApi',
51
        ];
52
        self::assertTrue($container->hasParameter('zibios_wrike'), json_encode($container->getParameterBag()));
53
        self::assertEquals($expectedConfiguration, $container->getParameter('zibios_wrike'));
54
    }
55
56
    public function testLoadWithOverwriting()
57
    {
58
        $container = $this->getContainer('overwriting');
59
60
        $expectedConfiguration = [
61
            'permanent_tokens' => [
62
                'tokens' => [
63
                    'first' => 'firstToken',
64
                    'second' => 'secondToken',
65
                    'third' => 'thirdToken',
66
                ],
67
                'default_token' => 'third',
68
            ],
69
            'api_url' => 'https://urlOverwritten',
70
        ];
71
        self::assertTrue($container->hasParameter('zibios_wrike'));
72
        self::assertEquals($expectedConfiguration, $container->getParameter('zibios_wrike'));
73
    }
74
75
    /**
76
     * @param string $fixture
77
     *
78
     * @return ContainerBuilder
79
     */
80
    protected function getContainer($fixture)
81
    {
82
        $container = new ContainerBuilder();
83
        $container->registerExtension(new ZibiosWrikeExtension());
84
        $this->loadFixture($container, $fixture);
85
        $container->compile();
86
87
        return $container;
88
    }
89
90
    /**
91
     * @param ContainerBuilder $container
92
     * @param string $fixture
93
     */
94
    abstract protected function loadFixture(ContainerBuilder $container, $fixture);
95
}
96