@@ -65,6 +65,31 @@ public function testClone()
65
65
$ this ->assertNull ($ clone ->getContainer ());
66
66
}
67
67
68
+ public function testInitializeContainerClearsOldContainers ()
69
+ {
70
+ $ fs = new Filesystem ();
71
+ $ legacyContainerDir = __DIR__ .'/Fixtures/cache/custom/ContainerA123456 ' ;
72
+ $ fs ->mkdir ($ legacyContainerDir );
73
+ touch ($ legacyContainerDir .'.legacy ' );
74
+
75
+ $ kernel = new CustomProjectDirKernel ();
76
+ $ kernel ->boot ();
77
+
78
+ $ containerDir = __DIR__ .'/Fixtures/cache/custom/ ' .substr (get_class ($ kernel ->getContainer ()), 0 , 16 );
79
+ $ this ->assertTrue (unlink (__DIR__ .'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta ' ));
80
+ $ this ->assertFileExists ($ containerDir );
81
+ $ this ->assertFileNotExists ($ containerDir .'.legacy ' );
82
+
83
+ $ kernel = new CustomProjectDirKernel (function ($ container ) { $ container ->register ('foo ' , 'stdClass ' )->setPublic (true ); });
84
+ $ kernel ->boot ();
85
+
86
+ $ this ->assertFileExists ($ containerDir );
87
+ $ this ->assertFileExists ($ containerDir .'.legacy ' );
88
+
89
+ $ this ->assertFileNotExists ($ legacyContainerDir );
90
+ $ this ->assertFileNotExists ($ legacyContainerDir .'.legacy ' );
91
+ }
92
+
68
93
public function testBootInitializesBundlesAndContainer ()
69
94
{
70
95
$ kernel = $ this ->getKernel (array ('initializeBundles ' , 'initializeContainer ' ));
@@ -1022,7 +1047,7 @@ protected function getHttpKernel()
1022
1047
1023
1048
class PassKernel extends CustomProjectDirKernel implements CompilerPassInterface
1024
1049
{
1025
- public function __construct (\ Closure $ buildContainer = null )
1050
+ public function __construct ()
1026
1051
{
1027
1052
parent ::__construct ();
1028
1053
Kernel::__construct ('pass ' , true );
0 commit comments