ClassMapBuilderTest::testBuild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 23
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
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 Yarhon\RouteGuardBundle\Tests\DependencyInjection\Container;
12
13
use PHPUnit\Framework\TestCase;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Yarhon\RouteGuardBundle\DependencyInjection\Container\ClassMapBuilder;
16
17
/**
18
 * @author Yaroslav Honcharuk <[email protected]>
19
 */
20
class ClassMapBuilderTest extends TestCase
21
{
22
    /**
23
     * @var ContainerBuilder
24
     */
25
    private $container;
26
27
    public function setUp()
28
    {
29
        $this->container = new ContainerBuilder();
30
    }
31
32
    public function testBuild()
33
    {
34
        $this->container->register('test1', 'test_class1')->setPublic(true);
35
        $this->container->register('test2', 'test_class2')->setPublic(true);
36
37
        // We don't use setAlias return value to be compatible with Symfony <3.4
38
        $this->container->setAlias('test1_alias', 'test1');
39
        $this->container->getAlias('test1_alias')->setPublic(true);
40
41
        $this->container->compile();
42
43
        $builder = new ClassMapBuilder();
44
        $map = $builder->build($this->container);
45
46
        $this->assertInternalType('array', $map);
47
48
        $expected = [
49
            'test1' => 'test_class1',
50
            'test1_alias' => 'test_class1',
51
            'test2' => 'test_class2',
52
        ];
53
54
        $this->assertArraySubset($expected, $map);
55
    }
56
}
57