Explorar o código

make it possible to hint the kernel dir via the phpunit.xml

Lukas Kahwe Smith %!s(int64=14) %!d(string=hai) anos
pai
achega
5390b16573
Modificáronse 1 ficheiros con 22 adicións e 18 borrados
  1. 22 18
      src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

+ 22 - 18
src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

@@ -62,26 +62,30 @@ abstract class WebTestCase extends BaseWebTestCase
      */
     protected function createKernel(array $options = array())
     {
-        // black magic below, you have been warned!
-        $dir = getcwd();
-        if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
-            throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
-        }
-
-        // find the --configuration flag from PHPUnit
-        $cli = implode(' ', $_SERVER['argv']);
-        if (preg_match('/\-\-configuration[= ]+([^ ]+)/', $cli, $matches)) {
-            $dir = $dir.'/'.$matches[1];
-        } elseif (preg_match('/\-c +([^ ]+)/', $cli, $matches)) {
-            $dir = $dir.'/'.$matches[1];
-        } elseif (file_exists(getcwd().'/phpunit.xml') || file_exists(getcwd().'/phpunit.xml.dist')) {
-            $dir = getcwd();
+        if (isset($_SERVER['KERNEL_DIR'])) {
+            $dir = $_SERVER['KERNEL_DIR'];
         } else {
-            throw new \RuntimeException('Unable to guess the Kernel directory.');
-        }
+            // black magic below, you have been warned!
+            $dir = getcwd();
+            if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
+                throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
+            }
+
+            // find the --configuration flag from PHPUnit
+            $cli = implode(' ', $_SERVER['argv']);
+            if (preg_match('/\-\-configuration[= ]+([^ ]+)/', $cli, $matches)) {
+                $dir = $dir.'/'.$matches[1];
+            } elseif (preg_match('/\-c +([^ ]+)/', $cli, $matches)) {
+                $dir = $dir.'/'.$matches[1];
+            } elseif (file_exists(getcwd().'/phpunit.xml') || file_exists(getcwd().'/phpunit.xml.dist')) {
+                $dir = getcwd();
+            } else {
+                throw new \RuntimeException('Unable to guess the Kernel directory.');
+            }
 
-        if (!is_dir($dir)) {
-            $dir = dirname($dir);
+            if (!is_dir($dir)) {
+                $dir = dirname($dir);
+            }
         }
 
         $finder = new Finder();