Code Duplication    Length = 44-46 lines in 2 locations

eZ/Bundle/EzPublishCoreBundle/Tests/DependencyInjection/Compiler/NotificationRendererPassTest.php 1 location

@@ 17-62 (lines=46) @@
14
use Symfony\Component\DependencyInjection\Definition;
15
use Symfony\Component\DependencyInjection\Reference;
16
17
class NotificationRendererPassTest extends AbstractCompilerPassTestCase
18
{
19
    const NOTIFICATION_RENDERER_ID = 'notification.renderer.id';
20
    const NOTIFICATION_ALIAS = 'example';
21
22
    protected function setUp()
23
    {
24
        parent::setUp();
25
26
        $this->setDefinition(NotificationRendererPass::REGISTRY_DEFINITION_ID, new Definition());
27
    }
28
29
    protected function registerCompilerPass(ContainerBuilder $container)
30
    {
31
        $container->addCompilerPass(new NotificationRendererPass());
32
    }
33
34
    public function testAddRenderer()
35
    {
36
        $definition = new Definition();
37
        $definition->addTag(NotificationRendererPass::TAG_NAME, [
38
            'alias' => self::NOTIFICATION_ALIAS,
39
        ]);
40
41
        $this->setDefinition(self::NOTIFICATION_RENDERER_ID, $definition);
42
        $this->compile();
43
44
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
45
            NotificationRendererPass::REGISTRY_DEFINITION_ID,
46
            'addRenderer',
47
            [self::NOTIFICATION_ALIAS, new Reference(self::NOTIFICATION_RENDERER_ID)]
48
        );
49
    }
50
51
    /**
52
     * @expectedException \LogicException
53
     */
54
    public function testAddRendererWithoutAliasThrowsLogicException()
55
    {
56
        $definition = new Definition();
57
        $definition->addTag(NotificationRendererPass::TAG_NAME);
58
59
        $this->setDefinition(self::NOTIFICATION_RENDERER_ID, $definition);
60
        $this->compile();
61
    }
62
}
63

eZ/Bundle/EzPublishCoreBundle/Tests/DependencyInjection/Compiler/PlaceholderProviderPassTest.php 1 location

@@ 17-60 (lines=44) @@
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