Revert "[HttpKernel] simplified some tests"

This reverts commit ccacd8d2af.
This commit is contained in:
Fabien Potencier 2014-05-26 18:41:51 +02:00
parent ccacd8d2af
commit 8d29ca160d

View File

@ -824,37 +824,48 @@ EOF;
$kernel->terminate(Request::create('/'), new Response());
}
/**
* @dataProvider getRemoveAbsolutePathsFromContainerData
*/
public function testRemoveAbsolutePathsFromContainer($symfonyRootDir, $realRootDir, $replacement, $replaced)
public function testRemoveAbsolutePathsFromContainer()
{
$kernel = new KernelForTest('dev', true);
$kernel->setRootDir($symfonyRootDir);
if (null !== $realRootDir) {
$kernel->setRealRootDir($realRootDir);
}
$kernel->setRootDir($symfonyRootDir = __DIR__.'/Fixtures/DumpedContainers/app');
$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 = str_replace('ROOT_DIR', $replacement, $content);
$content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content);
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
$m->setAccessible(true);
$newContent = $m->invoke($kernel, $content);
if ($replaced) {
$this->assertEquals(file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php'), $newContent);
} else {
$this->assertEquals($newContent, $content);
}
$this->assertEquals($newContent, $content);
}
public function getRemoveAbsolutePathsFromContainerData()
public function testRemoveAbsolutePathsFromContainerWithSpecialCase()
{
return array(
array(__DIR__.'/Fixtures/DumpedContainers/app', null, __DIR__.'/Fixtures/DumpedContainers', true),
array(sys_get_temp_dir(), null, __DIR__.'/Fixtures/DumpedContainers', false),
array('/app/app', '/app', '/app', true),
);
$kernel = new KernelForTest('dev', true);
$kernel->setRootDir('/app/app');
$kernel->setRealRootDir('/app');
$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);
}
/**