|
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
|
|
|
|