[HttpKernel] simplified some tests
This commit is contained in:
parent
9766c72324
commit
ccacd8d2af
@ -824,48 +824,37 @@ 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 = __DIR__.'/Fixtures/DumpedContainers/app');
|
$kernel->setRootDir($symfonyRootDir);
|
||||||
|
if (null !== $realRootDir) {
|
||||||
$content = file_get_contents($symfonyRootDir.'/cache/dev/withAbsolutePaths.php');
|
$kernel->setRealRootDir($realRootDir);
|
||||||
$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', __DIR__.'/Fixtures/DumpedContainers', $content);
|
$content = str_replace('ROOT_DIR', $replacement, $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(file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php'), $newContent);
|
||||||
|
} else {
|
||||||
$this->assertEquals($newContent, $content);
|
$this->assertEquals($newContent, $content);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testRemoveAbsolutePathsFromContainerWithSpecialCase()
|
public function getRemoveAbsolutePathsFromContainerData()
|
||||||
{
|
{
|
||||||
$kernel = new KernelForTest('dev', true);
|
return array(
|
||||||
$kernel->setRootDir('/app/app');
|
array(__DIR__.'/Fixtures/DumpedContainers/app', null, __DIR__.'/Fixtures/DumpedContainers', true),
|
||||||
$kernel->setRealRootDir('/app');
|
array(sys_get_temp_dir(), null, __DIR__.'/Fixtures/DumpedContainers', false),
|
||||||
$symfonyRootDir = __DIR__.'/Fixtures/DumpedContainers/app';
|
array('/app/app', '/app', '/app', true),
|
||||||
|
);
|
||||||
$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