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

PlaceholderProviderPassTest::testAddProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
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