1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Liip\MonitorBundle\Tests\DependencyInjection\Compiler; |
4
|
|
|
|
5
|
|
|
use Liip\MonitorBundle\DependencyInjection\Compiler\GroupRunnersCompilerPass; |
6
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
9
|
|
|
|
10
|
|
|
class GroupRunnersCompilerPassTest extends AbstractCompilerPassTestCase |
11
|
|
|
{ |
12
|
|
|
public function testProcess() |
13
|
|
|
{ |
14
|
|
|
$defaultGroup = 'groupe_par_défaut'; |
15
|
|
|
|
16
|
|
|
$runner = new Definition(); |
17
|
|
|
$this->setDefinition('liip_monitor.runner', $runner); |
18
|
|
|
$this->setParameter('liip_monitor.default_group', $defaultGroup); |
19
|
|
|
$this->setParameter('liip_monitor.checks', ['groups' => ['foo' => [], 'baz' => []]]); |
20
|
|
|
|
21
|
|
|
$fooCheck = new Definition(); |
22
|
|
|
$fooCheck->addTag('liip_monitor.check', ['group' => 'foo']); |
23
|
|
|
$fooCheck->addTag('liip_monitor.check', ['group' => 'foobar']); |
24
|
|
|
$this->setDefinition('acme.check.foo', $fooCheck); |
25
|
|
|
|
26
|
|
|
$barCheckCollection = new Definition(); |
27
|
|
|
$barCheckCollection->addTag('liip_monitor.check_collection', ['group' => 'bar']); |
28
|
|
|
$this->setDefinition('acme.check.bar', $barCheckCollection); |
29
|
|
|
|
30
|
|
|
$this->compile(); |
31
|
|
|
|
32
|
|
|
$this->assertContainerBuilderHasAlias('liip_monitor.runner', 'liip_monitor.runner_'.$defaultGroup); |
33
|
|
|
$this->assertContainerBuilderHasService('liip_monitor.runner_'.$defaultGroup); |
34
|
|
|
$this->assertContainerBuilderHasService('liip_monitor.runner_foo'); |
35
|
|
|
$this->assertContainerBuilderHasService('liip_monitor.runner_foobar'); |
36
|
|
|
$this->assertContainerBuilderHasService('liip_monitor.runner_bar'); |
37
|
|
|
$this->assertContainerBuilderHasService('liip_monitor.runner_baz'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function registerCompilerPass(ContainerBuilder $container): void |
41
|
|
|
{ |
42
|
|
|
$container->addCompilerPass(new GroupRunnersCompilerPass()); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|