1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Liip\MonitorBundle\Tests; |
4
|
|
|
|
5
|
|
|
use Liip\MonitorBundle\LiipMonitorBundle; |
6
|
|
|
use Symfony\Component\DependencyInjection\ChildDefinition; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Liip\MonitorBundle\Tests\LiipMonitorBundleTest. |
10
|
|
|
*/ |
11
|
|
|
class LiipMonitorBundleTest extends \PHPUnit\Framework\TestCase |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject |
15
|
|
|
*/ |
16
|
|
|
protected $container; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var LiipMonitorBundle |
20
|
|
|
*/ |
21
|
|
|
protected $bundle; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Test bundle build to add all required compiler passes. |
25
|
|
|
*/ |
26
|
|
|
public function testBuildWithCompilerPasses() |
27
|
|
|
{ |
28
|
|
|
$compilerPasses = array( |
29
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\CheckAssetsEnabledPass' => true, |
30
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\AddGroupsCompilerPass' => true, |
31
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\GroupRunnersCompilerPass' => true, |
32
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\CheckTagCompilerPass' => true, |
33
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\CheckCollectionTagCompilerPass' => true, |
34
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\AdditionalReporterCompilerPass' => true, |
35
|
|
|
); |
36
|
|
|
|
37
|
|
|
$this->container->expects($this->exactly(count($compilerPasses))) |
38
|
|
|
->method('addCompilerPass') |
39
|
|
|
->with($this->isInstanceOf('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')) |
40
|
|
|
->willReturnCallback( |
41
|
|
|
function ($compilerPass) use (&$compilerPasses) { |
42
|
|
|
$class = get_class($compilerPass); |
43
|
|
|
unset($compilerPasses[$class]); |
44
|
|
|
} |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
$definition = null; |
48
|
|
|
|
49
|
|
|
if (method_exists('Symfony\Component\DependencyInjection\ContainerBuilder', 'registerForAutoconfiguration')) { |
50
|
|
|
$this->container->method('registerForAutoconfiguration')->willReturn($definition = new ChildDefinition('')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->bundle->build($this->container); |
54
|
|
|
$this->assertEmpty($compilerPasses); |
55
|
|
|
|
56
|
|
|
if ($definition) { |
57
|
|
|
$this->assertTrue($definition->hasTag('liip_monitor.check')); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Sets up test. |
63
|
|
|
*/ |
64
|
|
|
protected function setUp() |
65
|
|
|
{ |
66
|
|
|
$this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder') |
67
|
|
|
->disableOriginalConstructor() |
68
|
|
|
->getMock(); |
69
|
|
|
|
70
|
|
|
$this->bundle = new LiipMonitorBundle(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|