Passed
Push — master ( d2e487...b38026 )
by Tobias
05:31
created

testIfCompilerPassCollectsServicesByAddingMethodCallsTheseWillExist()   A

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\StoragePass;
19
20
class StoragePassTest extends AbstractCompilerPassTestCase
21
{
22
    protected function registerCompilerPass(ContainerBuilder $container): void
23
    {
24
        $container->addCompilerPass(new StoragePass());
25
    }
26
27
    public function testIfCompilerPassCollectsServicesByAddingMethodCallsTheseWillExist(): void
28
    {
29
        $collectingService = new Definition();
30
        $this->setDefinition('php_translation.storage.foobar', $collectingService);
31
32
        $collectedService = new Definition();
33
        $collectedService->addTag('php_translation.storage', ['name' => 'foobar', 'type' => 'remote']);
34
        $this->setDefinition('collected_service', $collectedService);
35
36
        $this->compile();
37
38
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
39
            'php_translation.storage.foobar',
40
            'addRemoteStorage',
41
            [new Reference('collected_service')]
42
        );
43
    }
44
}
45