[FrameworkBundle] fixed getPhpUnitXmlDir to work with directory paths with spaces in them
This commit is contained in:
parent
52c3a1d53d
commit
5f6ddc200d
@ -55,20 +55,34 @@ abstract class WebTestCase extends BaseWebTestCase
|
|||||||
*/
|
*/
|
||||||
protected function getPhpUnitXmlDir()
|
protected function getPhpUnitXmlDir()
|
||||||
{
|
{
|
||||||
$dir = getcwd();
|
$dir = null;
|
||||||
if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
|
if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
|
||||||
throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
|
throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the --configuration flag from PHPUnit
|
// Find a configuration flag from cli
|
||||||
$cli = implode(' ', $_SERVER['argv']);
|
$possibleCliFlags = array('-c', '--configuration');
|
||||||
if (preg_match('/\-\-configuration[= ]+([^ ]+)/', $cli, $matches)) {
|
foreach ($possibleCliFlags as $possibleCliFlag) {
|
||||||
$dir = realpath($matches[1]);
|
$flagArgIndex = array_search($possibleCliFlag, $_SERVER['argv']);
|
||||||
} elseif (preg_match('/\-c +([^ ]+)/', $cli, $matches)) {
|
if ($flagArgIndex !== false) {
|
||||||
$dir = realpath($matches[1]);
|
$dir = $_SERVER['argv'][$flagArgIndex + 1];
|
||||||
} elseif (file_exists(getcwd().'/phpunit.xml') || file_exists(getcwd().'/phpunit.xml.dist')) {
|
break;
|
||||||
$dir = getcwd();
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// Find configuration file in current directory
|
||||||
|
if ($dir === null) {
|
||||||
|
$possiblePHPUnitFilenames = array('phpunit.xml', 'phpunit.xml.dist');
|
||||||
|
foreach ($possiblePHPUnitFilenames as $possiblePHPUnitFilename) {
|
||||||
|
if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $possiblePHPUnitFilename)) {
|
||||||
|
$dir = getcwd();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't continue
|
||||||
|
if ($dir === null) {
|
||||||
throw new \RuntimeException('Unable to guess the Kernel directory.');
|
throw new \RuntimeException('Unable to guess the Kernel directory.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user