ExtractorPassTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testIfCompilerPassCollectsServicesByAddingMethodCallsTheseWillExist() 0 15 1
A registerCompilerPass() 0 3 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\ExtractorPass;
19
use Translation\Extractor\Extractor;
20
21
class ExtractorPassTest extends AbstractCompilerPassTestCase
22
{
23
    protected function registerCompilerPass(ContainerBuilder $container): void
24
    {
25
        $container->addCompilerPass(new ExtractorPass());
26
    }
27
28
    public function testIfCompilerPassCollectsServicesByAddingMethodCallsTheseWillExist(): void
29
    {
30
        $collectingService = new Definition();
31
        $this->setDefinition(Extractor::class, $collectingService);
32
33
        $collectedService = new Definition();
34
        $collectedService->addTag('php_translation.extractor', ['type' => 'html']);
35
        $this->setDefinition('collected_service', $collectedService);
36
37
        $this->compile();
38
39
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
40
            Extractor::class,
41
            'addFileExtractor',
42
            [new Reference('collected_service')]
43
        );
44
    }
45
}
46