Revert "[HttpKernel] simplified some tests"
This reverts commit ccacd8d2af
.
This commit is contained in:
parent
ccacd8d2af
commit
8d29ca160d
@ -824,37 +824,48 @@ EOF;
|
|||||||
$kernel->terminate(Request::create('/'), new Response());
|
$kernel->terminate(Request::create('/'), new Response());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testRemoveAbsolutePathsFromContainer()
|
||||||
* @dataProvider getRemoveAbsolutePathsFromContainerData
|
|
||||||
*/
|
|
||||||
public function testRemoveAbsolutePathsFromContainer($symfonyRootDir, $realRootDir, $replacement, $replaced)
|
|
||||||
{
|
{
|
||||||
$kernel = new KernelForTest('dev', true);
|
$kernel = new KernelForTest('dev', true);
|
||||||
$kernel->setRootDir($symfonyRootDir);
|
$kernel->setRootDir($symfonyRootDir = __DIR__.'/Fixtures/DumpedContainers/app');
|
||||||
if (null !== $realRootDir) {
|
|
||||||
$kernel->setRealRootDir($realRootDir);
|
$content = file_get_contents($symfonyRootDir.'/cache/dev/withAbsolutePaths.php');
|
||||||
}
|
$content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content);
|
||||||
|
|
||||||
|
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
|
||||||
|
$m->setAccessible(true);
|
||||||
|
$content = $m->invoke($kernel, $content);
|
||||||
|
$this->assertEquals(file_get_contents($symfonyRootDir.'/cache/dev/withoutAbsolutePaths.php'), $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveAbsolutePathsFromContainerGiveUpWhenComposerJsonPathNotGuessable()
|
||||||
|
{
|
||||||
|
$kernel = new KernelForTest('dev', true);
|
||||||
|
$kernel->setRootDir($symfonyRootDir = sys_get_temp_dir());
|
||||||
|
|
||||||
$content = file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php');
|
$content = file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php');
|
||||||
$content = str_replace('ROOT_DIR', $replacement, $content);
|
$content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content);
|
||||||
|
|
||||||
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
|
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
|
||||||
$m->setAccessible(true);
|
$m->setAccessible(true);
|
||||||
$newContent = $m->invoke($kernel, $content);
|
$newContent = $m->invoke($kernel, $content);
|
||||||
if ($replaced) {
|
$this->assertEquals($newContent, $content);
|
||||||
$this->assertEquals(file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php'), $newContent);
|
|
||||||
} else {
|
|
||||||
$this->assertEquals($newContent, $content);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRemoveAbsolutePathsFromContainerData()
|
public function testRemoveAbsolutePathsFromContainerWithSpecialCase()
|
||||||
{
|
{
|
||||||
return array(
|
$kernel = new KernelForTest('dev', true);
|
||||||
array(__DIR__.'/Fixtures/DumpedContainers/app', null, __DIR__.'/Fixtures/DumpedContainers', true),
|
$kernel->setRootDir('/app/app');
|
||||||
array(sys_get_temp_dir(), null, __DIR__.'/Fixtures/DumpedContainers', false),
|
$kernel->setRealRootDir('/app');
|
||||||
array('/app/app', '/app', '/app', true),
|
$symfonyRootDir = __DIR__.'/Fixtures/DumpedContainers/app';
|
||||||
);
|
|
||||||
|
$content = file_get_contents($symfonyRootDir.'/cache/dev/withAbsolutePaths.php');
|
||||||
|
$content = str_replace('ROOT_DIR', '/app', $content);
|
||||||
|
|
||||||
|
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
|
||||||
|
$m->setAccessible(true);
|
||||||
|
$content = $m->invoke($kernel, $content);
|
||||||
|
$this->assertEquals(file_get_contents($symfonyRootDir.'/cache/dev/withoutAbsolutePaths.php'), $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user