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

StoragePassTest   A

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 registerCompilerPass() 0 3 1
A testIfCompilerPassCollectsServicesByAddingMethodCallsTheseWillExist() 0 15 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\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