@@ -771,13 +771,38 @@ public function testSymfonyEnvironmentVariables()
771
771
772
772
public function testProjectDirExtension ()
773
773
{
774
- $ kernel = new CustomProjectDirKernel (' test ' , true );
774
+ $ kernel = new CustomProjectDirKernel ();
775
775
$ kernel ->boot ();
776
776
777
777
$ this ->assertSame ('foo ' , $ kernel ->getProjectDir ());
778
778
$ this ->assertSame ('foo ' , $ kernel ->getContainer ()->getParameter ('kernel.project_dir ' ));
779
779
}
780
780
781
+ public function testKernelReset ()
782
+ {
783
+ (new Filesystem ())->remove (__DIR__ .'/Fixtures/cache ' );
784
+
785
+ $ kernel = new CustomProjectDirKernel ();
786
+ $ kernel ->boot ();
787
+
788
+ $ containerClass = get_class ($ kernel ->getContainer ());
789
+ $ containerFile = (new \ReflectionClass ($ kernel ->getContainer ()))->getFileName ();
790
+ unlink (__DIR__ .'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta ' );
791
+
792
+ $ kernel = new CustomProjectDirKernel ();
793
+ $ kernel ->boot ();
794
+
795
+ $ this ->assertSame ($ containerClass , get_class ($ kernel ->getContainer ()));
796
+ $ this ->assertFileExists ($ containerFile );
797
+ unlink (__DIR__ .'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta ' );
798
+
799
+ $ kernel = new CustomProjectDirKernel (function ($ container ) { $ container ->register ('foo ' , 'stdClass ' ); });
800
+ $ kernel ->boot ();
801
+
802
+ $ this ->assertTrue (get_class ($ kernel ->getContainer ()) !== $ containerClass );
803
+ $ this ->assertFileNotExists ($ containerFile );
804
+ }
805
+
781
806
/**
782
807
* Returns a mock for the BundleInterface.
783
808
*
@@ -878,12 +903,14 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
878
903
class CustomProjectDirKernel extends Kernel
879
904
{
880
905
private $ baseDir ;
906
+ private $ buildContainer ;
881
907
882
- public function __construct ()
908
+ public function __construct (\ Closure $ buildContainer = null )
883
909
{
884
- parent ::__construct ('test ' , false );
910
+ parent ::__construct ('custom ' , true );
885
911
886
912
$ this ->baseDir = 'foo ' ;
913
+ $ this ->buildContainer = $ buildContainer ;
887
914
}
888
915
889
916
public function registerBundles ()
@@ -904,4 +931,11 @@ public function getRootDir()
904
931
{
905
932
return __DIR__ .'/Fixtures ' ;
906
933
}
934
+
935
+ protected function build (ContainerBuilder $ container )
936
+ {
937
+ if ($ build = $ this ->buildContainer ) {
938
+ $ build ($ container );
939
+ }
940
+ }
907
941
}
0 commit comments