Completed
Push — master ( e81671...a22352 )
by André
93:06 queued 73:42
created

URLHandlerPassTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the SignalSlotPassTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler;
10
11
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\URLHandlerPass;
12
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Definition;
15
use Symfony\Component\DependencyInjection\Reference;
16
17
class URLHandlerPassTest extends AbstractCompilerPassTestCase
18
{
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
        $this->setDefinition('ezpublish.url_checker.handler_registry', new Definition());
23
    }
24
25
    protected function registerCompilerPass(ContainerBuilder $container)
26
    {
27
        $container->addCompilerPass(new URLHandlerPass());
28
    }
29
30
    public function testRegisterURLHandler()
31
    {
32
        $serviceId = 'service_id';
33
        $scheme = 'http';
34
        $definition = new Definition();
35
        $definition->addTag('ezpublish.url_handler', ['scheme' => $scheme]);
36
        $this->setDefinition($serviceId, $definition);
37
38
        $this->compile();
39
40
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
41
            'ezpublish.url_checker.handler_registry',
42
            'addHandler',
43
            array($scheme, new Reference($serviceId))
44
        );
45
    }
46
47
    /**
48
     * @expectedException \LogicException
49
     */
50
    public function testRegisterURLHandlerNoScheme()
51
    {
52
        $serviceId = 'service_id';
53
        $scheme = 'http';
54
        $definition = new Definition();
55
        $definition->addTag('ezpublish.url_handler');
56
        $this->setDefinition($serviceId, $definition);
57
58
        $this->compile();
59
60
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
61
            'ezpublish.url_checker.handler_registry',
62
            'addHandler',
63
            array($scheme, new Reference($serviceId))
64
        );
65
    }
66
}
67