Completed
Push — master ( ea9d41...184c59 )
by Sergii
08:21
created

AppExtensionTest::testParametersSet()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 40
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
c 0
b 0
f 0
rs 8.8571
cc 2
eloc 25
nc 2
nop 0
1
<?php
2
namespace Tests\AppBundle\DependencyInjection;
3
4
use AppBundle\DependencyInjection\AppExtension;
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
7
/**
8
 * App Extension tests
9
 *
10
 * @author Sergey Sadovoi <[email protected]>
11
 */
12
class AppExtensionTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var AppExtension
16
     */
17
    private $extension;
18
19
    public function setUp()
20
    {
21
        parent::setUp();
22
23
        $this->extension = $this->getExtension();
24
    }
25
26
    public function testParametersSet()
27
    {
28
        $config = [
29
            'sync' => [
30
                'master' => [
31
                    'storage' => 'local',
32
                    'path'    => '/test/path',
33
                    'filters' => [],
34
                ],
35
                'slave' => [
36
                    'storage'  => 'local',
37
                    'path'     => '/test/path',
38
                    'path_tpl' => '/test/path/tpl',
39
                    'filters'  => [],
40
                ],
41
            ],
42
        ];
43
44
        $container = $this->getContainer();
45
        $container->setParameter('app.logger', 'test_logger');
46
47
        $this->extension->load($config, $container);
48
49
        // Test parameters
50
        $parameters = [
51
            'master.path',
52
            'master.filters',
53
            'slave.path',
54
            'slave.path_tpl',
55
            'slave.filters',
56
        ];
57
58
        foreach ($parameters as $param) {
59
            $this->assertTrue($container->hasParameter($param));
60
        }
61
62
        // Test storage alias
63
        $this->assertTrue($container->hasAlias('master.storage'));
64
        $this->assertTrue($container->hasAlias('slave.storage'));
65
    }
66
67
    protected function getExtension()
68
    {
69
        return new AppExtension();
70
    }
71
72
    private function getContainer()
73
    {
74
        $container = new ContainerBuilder();
75
76
        return $container;
77
    }
78
}
79