From 8d29ca160d02b1e3cee6f87fa55e61505b054e24 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 26 May 2014 18:41:51 +0200 Subject: [PATCH] Revert "[HttpKernel] simplified some tests" This reverts commit ccacd8d2af428de1cf3df3e25757d4e4a20ab5e1. --- .../Component/HttpKernel/Tests/KernelTest.php | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 82a7561377..d2a22c6ae4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -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); } /**