Completed
Push — 6.13 ( 9c335d...8c8805 )
by
unknown
16:33
created

registerCompilerPass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the RichTextHtml5ConverterPassTest 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\RichTextHtml5ConverterPass;
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 RichTextHtml5ConverterPassTest extends AbstractCompilerPassTestCase
18
{
19
    /**
20
     * Register the compiler pass under test, just like you would do inside a bundle's load()
21
     * method:.
22
     *
23
     *   $container->addCompilerPass(new MyCompilerPass());
24
     */
25
    protected function registerCompilerPass(ContainerBuilder $container)
26
    {
27
        $container->addCompilerPass(new RichTextHtml5ConverterPass());
28
    }
29
30
    public function testCollectProviders()
31
    {
32
        $configurationResolver = new Definition();
33
        $this->setDefinition(
34
            'ezpublish.fieldType.ezrichtext.converter.output.xhtml5',
35
            $configurationResolver
36
        );
37
38
        $configurationProvider = new Definition();
39
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5');
40
        $this->setDefinition('ezrichtext.converter.test1', $configurationProvider);
41
42
        $configurationProvider = new Definition();
43
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5', ['priority' => 10]);
44
        $this->setDefinition('ezrichtext.converter.test2', $configurationProvider);
45
46
        $configurationProvider = new Definition();
47
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5', ['priority' => 5]);
48
        $this->setDefinition('ezrichtext.converter.test3', $configurationProvider);
49
50
        $configurationProvider = new Definition();
51
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5', ['priority' => 5]);
52
        $this->setDefinition('ezrichtext.converter.test4', $configurationProvider);
53
54
        $this->compile();
55
56
        $this->assertContainerBuilderHasServiceDefinitionWithArgument(
57
            'ezpublish.fieldType.ezrichtext.converter.output.xhtml5',
58
            0,
59
            [
60
                new Reference('ezrichtext.converter.test1'),
61
                new Reference('ezrichtext.converter.test3'),
62
                new Reference('ezrichtext.converter.test4'),
63
                new Reference('ezrichtext.converter.test2'),
64
            ]
65
        );
66
    }
67
}
68