10000 Revert "[HttpKernel] simplified some tests" · symfony/symfony@8d29ca1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d29ca1

Browse files
committed
Revert "[HttpKernel] simplified some tests"
This reverts commit ccacd8d.
1 parent ccacd8d commit 8d29ca1

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -824,37 +824,48 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
824824
$kernel->terminate(Request::create('/'), new Response());
825825
}
826826

827-
/**
828-
* @dataProvider getRemoveAbsolutePathsFromContainerData
829-
*/
830-
public function testRemoveAbsolutePathsFromContainer($symfonyRootDir, $realRootDir, $replacement, $replaced)
827+
public function testRemoveAbsolutePathsFromContainer()
831828
{
832829
$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());
837845

838846
$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);
840848

841849
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
842850
$m->setAccessible(true);
843851
$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);
849853
}
850854

851-
public function getRemoveAbsolutePathsFromContainerData()
855+
public function testRemoveAbsolutePathsFromContainerWithSpecialCase()
852856
{
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);
858869
}
859870

860871
/**

0 commit comments

Comments
 (0)
0