@@ -824,37 +824,48 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
824
824
$ kernel ->terminate (Request::create ('/ ' ), new Response ());
825
825
}
826
826
827
- /**
828
- * @dataProvider getRemoveAbsolutePathsFromContainerData
829
- */
830
- public function testRemoveAbsolutePathsFromContainer ($ symfonyRootDir , $ realRootDir , $ replacement , $ replaced )
827
+ public function testRemoveAbsolutePathsFromContainer ()
831
828
{
832
829
$ kernel = new KernelForTest ('dev ' , true );
833
- $ kernel ->setRootDir ($ symfonyRootDir );
834
- if (null !== $ realRootDir ) {
835
- $ kernel ->setRealRootDir ($ realRootDir );
836
- }
830
+ $ kernel ->setRootDir ($ symfonyRootDir = __DIR__ .'/Fixtures/DumpedContainers/app ' );
831
+
832
+ $ content = file_get_contents ($ symfonyRootDir .'/cache/dev/withAbsolutePaths.php ' );
833
+ $ content = str_replace ('ROOT_DIR ' , __DIR__ .'/Fixtures/DumpedContainers ' , $ content );
834
+
835
+ $ m = new \ReflectionMethod ($ kernel , 'removeAbsolutePathsFromContainer ' );
836
+ $ m ->setAccessible (true );
837
+ $ content = $ m ->invoke ($ kernel , $ content );
838
+ $ this ->assertEquals (file_get_contents ($ symfonyRootDir .'/cache/dev/withoutAbsolutePaths.php ' ), $ content );
839
+ }
840
+
841
+ public function testRemoveAbsolutePathsFromContainerGiveUpWhenComposerJsonPathNotGuessable ()
842
+ {
843
+ $ kernel = new KernelForTest ('dev ' , true );
844
+ $ kernel ->setRootDir ($ symfonyRootDir = sys_get_temp_dir ());
837
845
838
846
$ content = file_get_contents (__DIR__ .'/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php ' );
839
- $ content = str_replace ('ROOT_DIR ' , $ replacement , $ content );
847
+ $ content = str_replace ('ROOT_DIR ' , __DIR__ . ' /Fixtures/DumpedContainers ' , $ content );
840
848
841
849
$ m = new \ReflectionMethod ($ kernel , 'removeAbsolutePathsFromContainer ' );
842
850
$ m ->setAccessible (true );
843
851
$ newContent = $ m ->invoke ($ kernel , $ content );
844
- if ($ replaced ) {
845
- $ this ->assertEquals (file_get_contents (__DIR__ .'/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php ' ), $ newContent );
846
- } else {
847
- $ this ->assertEquals ($ newContent , $ content );
848
- }
852
+ $ this ->assertEquals ($ newContent , $ content );
849
853
}
850
854
851
- public function getRemoveAbsolutePathsFromContainerData ()
855
+ public function testRemoveAbsolutePathsFromContainerWithSpecialCase ()
852
856
{
853
- return array (
854
- array (__DIR__ .'/Fixtures/DumpedContainers/app ' , null , __DIR__ .'/Fixtures/DumpedContainers ' , true ),
855
- array (sys_get_temp_dir (), null , __DIR__ .'/Fixtures/DumpedContainers ' , false ),
856
- array ('/app/app ' , '/app ' , '/app ' , true ),
857
- );
857
+ $ kernel = new KernelForTest ('dev ' , true );
858
+ $ kernel ->setRootDir ('/app/app ' );
859
+ $ kernel ->setRealRootDir ('/app ' );
860
+ $ symfonyRootDir = __DIR__ .'/Fixtures/DumpedContainers/app ' ;
861
+
862
+ $ content = file_get_contents ($ symfonyRootDir .'/cache/dev/withAbsolutePaths.php ' );
863
+ $ content = str_replace ('ROOT_DIR ' , '/app ' , $ content );
864
+
865
+ $ m = new \ReflectionMethod ($ kernel , 'removeAbsolutePathsFromContainer ' );
866
+ $ m ->setAccessible (true );
867
+ $ content = $ m ->invoke ($ kernel , $ content );
868
+ $ this ->assertEquals (file_get_contents ($ symfonyRootDir .'/cache/dev/withoutAbsolutePaths.php ' ), $ content );
858
869
}
859
870
860
871
/**
0 commit comments