Completed
Push — ezp28890-fix_in_context_transl... ( c620fe...b89572 )
by
unknown
22:17
created

PlaceholderProviderPassTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A registerCompilerPass() 0 4 1
A testAddProvider() 0 14 1
A testAddProviderWithoutType() 0 8 1
1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
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\PlaceholderProviderPass;
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 PlaceholderProviderPassTest extends AbstractCompilerPassTestCase
18
{
19
    const PROVIDER_ID = 'provider.id';
20
    const PROVIDER_TYPE = 'provider.test';
21
22
    protected function setUp()
23
    {
24
        parent::setUp();
25
26
        $this->setDefinition(PlaceholderProviderPass::REGISTRY_DEFINITION_ID, new Definition());
27
    }
28
29
    protected function registerCompilerPass(ContainerBuilder $container)
30
    {
31
        $container->addCompilerPass(new PlaceholderProviderPass());
32
    }
33
34
    public function testAddProvider()
35
    {
36
        $definition = new Definition();
37
        $definition->addTag(PlaceholderProviderPass::TAG_NAME, ['type' => self::PROVIDER_TYPE]);
38
39
        $this->setDefinition(self::PROVIDER_ID, $definition);
40
        $this->compile();
41
42
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
43
            PlaceholderProviderPass::REGISTRY_DEFINITION_ID,
44
            'addProvider',
45
            [self::PROVIDER_TYPE, new Reference(self::PROVIDER_ID)]
46
        );
47
    }
48
49
    /**
50
     * @expectedException \LogicException
51
     */
52
    public function testAddProviderWithoutType()
53
    {
54
        $definition = new Definition();
55
        $definition->addTag(PlaceholderProviderPass::TAG_NAME);
56
57
        $this->setDefinition(self::PROVIDER_ID, $definition);
58
        $this->compile();
59
    }
60
}
61