testIfCompilerPassCollectsServicesByAddingMethodCallsTheseWillExist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9332
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