EditInPlacePassTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCompilerPass() 0 3 1
A testReplacement() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Bundle\Tests\Unit\DependencyInjection\CompilerPass;
13
14
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\Reference;
18
use Translation\Bundle\DependencyInjection\CompilerPass\EditInPlacePass;
19
use Translation\Bundle\Translator\EditInPlaceTranslator;
20
21
class EditInPlacePassTest extends AbstractCompilerPassTestCase
22
{
23
    protected function registerCompilerPass(ContainerBuilder $container): void
24
    {
25
        $container->addCompilerPass(new EditInPlacePass());
26
    }
27
28
    public function testReplacement(): void
29
    {
30
        $def = new Definition();
31
        $this->setDefinition(EditInPlaceTranslator::class, $def);
32
33
        $twigExtension = new Definition();
34
        $twigExtension->addArgument('should_be_replaced');
35
        $this->setDefinition('twig.extension.trans', $twigExtension);
36
37
        $this->compile();
38
39
        $this->assertContainerBuilderHasServiceDefinitionWithArgument('twig.extension.trans', 0, new Reference(EditInPlaceTranslator::class));
40
    }
41
}
42