|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Lug package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Lug\Bundle\ResourceBundle\Tests; |
|
13
|
|
|
|
|
14
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\ConfigureResolveTargetEntitySubscriberPass; |
|
15
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterDomainManagerPass; |
|
16
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterDriverMappingPass; |
|
17
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterFactoryPass; |
|
18
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterFlashListenerPass; |
|
19
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterManagerPass; |
|
20
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterManagerTagPass; |
|
21
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterMessageListenerPass; |
|
22
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterRepositoryPass; |
|
23
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterResourcePass; |
|
24
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\ReplaceBase64FileExtensionPass; |
|
25
|
|
|
use Lug\Bundle\ResourceBundle\DependencyInjection\Compiler\ReplaceBooleanExtensionPass; |
|
26
|
|
|
use Lug\Bundle\ResourceBundle\LugResourceBundle; |
|
27
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
28
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @author GeLo <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class LugResourceBundleTest extends \PHPUnit_Framework_TestCase |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var LugResourceBundle |
|
37
|
|
|
*/ |
|
38
|
|
|
private $bundle; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
|
|
protected function setUp() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->bundle = new LugResourceBundle(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testInheritance() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->assertInstanceOf(Bundle::class, $this->bundle); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testBuild() |
|
54
|
|
|
{ |
|
55
|
|
|
$container = $this->createContainerBuilderMock(); |
|
56
|
|
|
$container |
|
|
|
|
|
|
57
|
|
|
->expects($this->at(0)) |
|
58
|
|
|
->method('addCompilerPass') |
|
59
|
|
|
->with($this->isInstanceOf(RegisterResourcePass::class)) |
|
60
|
|
|
->will($this->returnSelf()); |
|
61
|
|
|
|
|
62
|
|
|
$container |
|
63
|
|
|
->expects($this->at(1)) |
|
64
|
|
|
->method('addCompilerPass') |
|
65
|
|
|
->with($this->isInstanceOf(RegisterDriverMappingPass::class)) |
|
66
|
|
|
->will($this->returnSelf()); |
|
67
|
|
|
|
|
68
|
|
|
$container |
|
69
|
|
|
->expects($this->at(2)) |
|
70
|
|
|
->method('addCompilerPass') |
|
71
|
|
|
->with($this->isInstanceOf(RegisterFactoryPass::class)) |
|
72
|
|
|
->will($this->returnSelf()); |
|
73
|
|
|
|
|
74
|
|
|
$container |
|
75
|
|
|
->expects($this->at(3)) |
|
76
|
|
|
->method('addCompilerPass') |
|
77
|
|
|
->with($this->isInstanceOf(RegisterManagerTagPass::class)) |
|
78
|
|
|
->will($this->returnSelf()); |
|
79
|
|
|
|
|
80
|
|
|
$container |
|
81
|
|
|
->expects($this->at(4)) |
|
82
|
|
|
->method('addCompilerPass') |
|
83
|
|
|
->with($this->isInstanceOf(RegisterManagerPass::class)) |
|
84
|
|
|
->will($this->returnSelf()); |
|
85
|
|
|
|
|
86
|
|
|
$container |
|
87
|
|
|
->expects($this->at(5)) |
|
88
|
|
|
->method('addCompilerPass') |
|
89
|
|
|
->with($this->isInstanceOf(RegisterRepositoryPass::class)) |
|
90
|
|
|
->will($this->returnSelf()); |
|
91
|
|
|
|
|
92
|
|
|
$container |
|
93
|
|
|
->expects($this->at(6)) |
|
94
|
|
|
->method('addCompilerPass') |
|
95
|
|
|
->with($this->isInstanceOf(RegisterDomainManagerPass::class)) |
|
96
|
|
|
->will($this->returnSelf()); |
|
97
|
|
|
|
|
98
|
|
|
$container |
|
99
|
|
|
->expects($this->at(7)) |
|
100
|
|
|
->method('addCompilerPass') |
|
101
|
|
|
->with($this->isInstanceOf(ConfigureResolveTargetEntitySubscriberPass::class)) |
|
102
|
|
|
->will($this->returnSelf()); |
|
103
|
|
|
|
|
104
|
|
|
$container |
|
105
|
|
|
->expects($this->at(8)) |
|
106
|
|
|
->method('addCompilerPass') |
|
107
|
|
|
->with($this->isInstanceOf(RegisterFlashListenerPass::class)) |
|
108
|
|
|
->will($this->returnSelf()); |
|
109
|
|
|
|
|
110
|
|
|
$container |
|
111
|
|
|
->expects($this->at(9)) |
|
112
|
|
|
->method('addCompilerPass') |
|
113
|
|
|
->with($this->isInstanceOf(RegisterMessageListenerPass::class)) |
|
114
|
|
|
->will($this->returnSelf()); |
|
115
|
|
|
|
|
116
|
|
|
$container |
|
117
|
|
|
->expects($this->at(10)) |
|
118
|
|
|
->method('addCompilerPass') |
|
119
|
|
|
->with($this->isInstanceOf(ReplaceBase64FileExtensionPass::class)) |
|
120
|
|
|
->will($this->returnSelf()); |
|
121
|
|
|
|
|
122
|
|
|
$container |
|
123
|
|
|
->expects($this->at(11)) |
|
124
|
|
|
->method('addCompilerPass') |
|
125
|
|
|
->with($this->isInstanceOf(ReplaceBooleanExtensionPass::class)) |
|
126
|
|
|
->will($this->returnSelf()); |
|
127
|
|
|
|
|
128
|
|
|
$this->bundle->build($container); |
|
|
|
|
|
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject|ContainerBuilder |
|
133
|
|
|
*/ |
|
134
|
|
|
private function createContainerBuilderMock() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->getMock(ContainerBuilder::class); |
|
|
|
|
|
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: