Completed
Push — 7.5 ( 966769...7b2167 )
by
unknown
19:17 queued 11s
created

testCollectProviders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 37
rs 9.328
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler;
8
9
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\RichTextHtml5ConverterPass;
10
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Definition;
13
use Symfony\Component\DependencyInjection\Reference;
14
15
class RichTextHtml5ConverterPassTest extends AbstractCompilerPassTestCase
16
{
17
    /**
18
     * Register the compiler pass under test, just like you would do inside a bundle's load()
19
     * method:.
20
     *
21
     *   $container->addCompilerPass(new MyCompilerPass());
22
     */
23
    protected function registerCompilerPass(ContainerBuilder $container)
24
    {
25
        $container->addCompilerPass(new RichTextHtml5ConverterPass());
26
    }
27
28
    public function testCollectProviders()
29
    {
30
        $configurationResolver = new Definition();
31
        $this->setDefinition(
32
            'ezpublish.fieldType.ezrichtext.converter.output.xhtml5',
33
            $configurationResolver
34
        );
35
36
        $configurationProvider = new Definition();
37
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5');
38
        $this->setDefinition('ezrichtext.converter.test1', $configurationProvider);
39
40
        $configurationProvider = new Definition();
41
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5', ['priority' => 10]);
42
        $this->setDefinition('ezrichtext.converter.test2', $configurationProvider);
43
44
        $configurationProvider = new Definition();
45
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5', ['priority' => 5]);
46
        $this->setDefinition('ezrichtext.converter.test3', $configurationProvider);
47
48
        $configurationProvider = new Definition();
49
        $configurationProvider->addTag('ezpublish.ezrichtext.converter.output.xhtml5', ['priority' => 5]);
50
        $this->setDefinition('ezrichtext.converter.test4', $configurationProvider);
51
52
        $this->compile();
53
54
        $this->assertContainerBuilderHasServiceDefinitionWithArgument(
55
            'ezpublish.fieldType.ezrichtext.converter.output.xhtml5',
56
            0,
57
            [
58
                new Reference('ezrichtext.converter.test1'),
59
                new Reference('ezrichtext.converter.test3'),
60
                new Reference('ezrichtext.converter.test4'),
61
                new Reference('ezrichtext.converter.test2'),
62
            ]
63
        );
64
    }
65
}
66