Skip to content

Commit

Permalink
make it possible to hint the kernel dir via the phpunit.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 authored and fabpot committed Jan 7, 2011
1 parent 46d8c4a commit 5390b16
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php
Expand Up @@ -62,26 +62,30 @@ public function createClient(array $options = array(), array $server = array())
*/
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();
Expand Down

0 comments on commit 5390b16

Please sign in to comment.