AddGroupsCompilerPassTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 54
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testProcess() 0 46 1
A registerCompilerPass() 0 4 1
1
<?php
2
3
namespace Liip\MonitorBundle\Tests\DependencyInjection\Compiler;
4
5
use Liip\MonitorBundle\DependencyInjection\Compiler\AddGroupsCompilerPass;
6
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Definition;
9
10
class AddGroupsCompilerPassTest extends AbstractCompilerPassTestCase
11
{
12
    public function testProcess()
13
    {
14
        $checkConfig = [
15
            'groups' => [
16
                'default' => [
17
                    'check1' => [],
18
                ],
19
                'app_server' => [
20
                    'check1' => [],
21
                    'check_collection1' => [],
22
                ],
23
            ],
24
        ];
25
        $this->setParameter('liip_monitor.checks', $checkConfig);
26
27
        $check1 = new Definition();
28
        $check1->addTag('liip_monitor.check', ['alias' => 'check1']);
29
        $this->setDefinition('liip_monitor.check.check1', $check1);
30
31
        $checkCollection1 = new Definition();
32
        $checkCollection1->addTag('liip_monitor.check_collection');
33
        $this->setDefinition('liip_monitor.check.check_collection1', $checkCollection1);
34
35
        $this->compile();
36
37
        $this->assertContainerBuilderHasServiceDefinitionWithTag(
38
            'liip_monitor.check.check1.default',
39
            'liip_monitor.check',
40
            ['group' => 'default', 'alias' => 'check1']
41
        );
42
43
        $this->assertContainerBuilderHasServiceDefinitionWithTag(
44
            'liip_monitor.check.check1.app_server',
45
            'liip_monitor.check',
46
            ['group' => 'app_server', 'alias' => 'check1']
47
        );
48
49
        $this->assertContainerBuilderHasServiceDefinitionWithTag(
50
            'liip_monitor.check.check_collection1.app_server',
51
            'liip_monitor.check_collection',
52
            ['group' => 'app_server', 'alias' => 'check_collection1']
53
        );
54
55
        $this->assertContainerBuilderNotHasService('liip_monitor.check.check1');
56
        $this->assertContainerBuilderNotHasService('liip_monitor.check.check_collection1');
57
    }
58
59
    protected function registerCompilerPass(ContainerBuilder $container): void
60
    {
61
        $container->addCompilerPass(new AddGroupsCompilerPass());
62
    }
63
}
64