|
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 = array( |
|
15
|
|
|
'groups' => array( |
|
16
|
|
|
'default' => array( |
|
17
|
|
|
'check1' => array(), |
|
18
|
|
|
), |
|
19
|
|
|
'app_server' => array( |
|
20
|
|
|
'check1' => array(), |
|
21
|
|
|
'check_collection1' => array(), |
|
22
|
|
|
), |
|
23
|
|
|
), |
|
24
|
|
|
); |
|
25
|
|
|
$this->setParameter('liip_monitor.checks', $checkConfig); |
|
26
|
|
|
|
|
27
|
|
|
$check1 = new Definition(); |
|
28
|
|
|
$check1->addTag('liip_monitor.check', array('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
|
|
|
array('group' => 'default', 'alias' => 'check1') |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithTag( |
|
44
|
|
|
'liip_monitor.check.check1.app_server', |
|
45
|
|
|
'liip_monitor.check', |
|
46
|
|
|
array('group' => 'app_server', 'alias' => 'check1') |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithTag( |
|
50
|
|
|
'liip_monitor.check.check_collection1.app_server', |
|
51
|
|
|
'liip_monitor.check_collection', |
|
52
|
|
|
array('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) |
|
60
|
|
|
{ |
|
61
|
|
|
$container->addCompilerPass(new AddGroupsCompilerPass()); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|