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