@@ -142,6 +142,53 @@ public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce()
142
142
$ kernel ->boot ();
143
143
}
144
144
145
+ public function providerSfCompilerDeprecationsEnvVarOnlySetIfContainerAlreadyBuilt ()
146
+ {
147
+ return array (
148
+ array (true , true , true , true ),
149
+ array (true , false , false , false ),
150
+ array (false , true , true , false ),
151
+ array (false , false , true , false ),
152
+ );
153
+ }
154
+
155
+ /**
156
+ * @dataProvider providerSfCompilerDeprecationsEnvVarOnlySetIfContainerAlreadyBuilt
157
+ */
158
+ public function testSfCompilerDeprecationsEnvVarOnlySetIfContainerAlreadyBuilt ($ isDebugMode , $ cacheIsFresh , $ resetEnvVar , $ expectedSymfonyCompilerDeprecationsSet )
159
+ {
160
+ if ($ resetEnvVar ) {
161
+ putenv ('SYMFONY_COMPILER_DEPRECATIONS ' );
162
+ }
163
+
164
+ $ kernel = $ this ->getKernel (array ('getCacheDir ' , 'isPhpunitComposerInstallDefined ' ), array (), $ isDebugMode );
165
+
166
+ $ fs = new Filesystem ();
167
+ $ cacheDir = __DIR__ .'/Fixtures/cache/mycachedir ' ;
168
+ $ fs ->mkdir ($ cacheDir );
169
+ $ containerFile = sprintf ('%s/MockObject%sTestDebugContainer.php ' , $ cacheDir , get_class ($ kernel ));
170
+ $ fs ->dumpFile ($ containerFile , '<?php return new Symfony\Component\DependencyInjection\ContainerBuilder(); ' );
171
+ if ($ cacheIsFresh ) {
172
+ $ fs ->dumpFile ($ containerFile .'.meta ' , serialize (array ()));
173
+ }
174
+ $ kernel
175
+ ->method ('getCacheDir ' )
176
+ ->willReturn ($ cacheDir );
177
+ $ kernel
178
+ ->method ('isPhpunitComposerInstallDefined ' )
179
+ ->willReturn (false );
180
+ $ kernel ->boot ();
181
+ if ($ expectedSymfonyCompilerDeprecationsSet ) {
182
+ $ this ->assertEquals (
183
+ sprintf ('%s/MockObject%sTestDebugContainerDeprecations.log ' , $ cacheDir , get_class ($ kernel )),
184
+ getenv ('SYMFONY_COMPILER_DEPRECATIONS ' )
185
+ );
186
+ } else {
187
+ $ this ->assertFalse (getenv ('SYMFONY_COMPILER_DEPRECATIONS ' ));
188
+ }
189
+ $ fs ->remove ($ cacheDir );
190
+ }
191
+
145
192
public function testShutdownCallsShutdownOnAllBundles ()
146
193
{
147
194
$ bundle = $ this ->getMockBuilder ('Symfony\Component\HttpKernel\Bundle\Bundle ' )->getMock ();
@@ -650,17 +697,18 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
650
697
*
651
698
* @param array $methods Additional methods to mock (besides the abstract ones)
652
699
* @param array $bundles Bundles to register
700
+ * @param bool $debug Whether debug mode is activated
653
701
*
654
702
* @return Kernel
655
703
*/
656
- protected function getKernel (array $ methods = array (), array $ bundles = array ())
704
+ protected function getKernel (array $ methods = array (), array $ bundles = array (), $ debug = false )
657
705
{
658
706
$ methods [] = 'registerBundles ' ;
659
707
660
708
$ kernel = $ this
661
709
->getMockBuilder ('Symfony\Component\HttpKernel\Kernel ' )
662
710
->setMethods ($ methods )
663
- ->setConstructorArgs (array ('test ' , false ))
711
+ ->setConstructorArgs (array ('test ' , $ debug ))
664
712
->getMockForAbstractClass ()
665
713
;
666
714
$ kernel ->expects ($ this ->any ())
0 commit comments