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 = [ |
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
|
|
|
'Liip\MonitorBundle\DependencyInjection\Compiler\MailerCompilerPass' => true, |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
$this->container->expects($this->exactly(count($compilerPasses))) |
39
|
|
|
->method('addCompilerPass') |
40
|
|
|
->with($this->isInstanceOf('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')) |
41
|
|
|
->willReturnCallback( |
42
|
|
|
function ($compilerPass) use (&$compilerPasses) { |
43
|
|
|
$class = get_class($compilerPass); |
44
|
|
|
unset($compilerPasses[$class]); |
45
|
|
|
} |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
$definition = null; |
49
|
|
|
|
50
|
|
|
if (method_exists('Symfony\Component\DependencyInjection\ContainerBuilder', 'registerForAutoconfiguration')) { |
51
|
|
|
$this->container->method('registerForAutoconfiguration')->willReturn($definition = new ChildDefinition('')); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
$this->bundle->build($this->container); |
55
|
|
|
$this->assertEmpty($compilerPasses); |
56
|
|
|
|
57
|
|
|
if ($definition) { |
58
|
|
|
$this->assertTrue($definition->hasTag('liip_monitor.check')); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Sets up test. |
64
|
|
|
*/ |
65
|
|
|
protected function setUp(): void |
66
|
|
|
{ |
67
|
|
|
$this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder') |
|
|
|
|
68
|
|
|
->disableOriginalConstructor() |
69
|
|
|
->getMock(); |
70
|
|
|
|
71
|
|
|
$this->bundle = new LiipMonitorBundle(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..