diff --git a/PHPCI/Plugin/Option/PhpUnitOptions.php b/PHPCI/Plugin/Option/PhpUnitOptions.php index 8bb9420a..4387da1c 100644 --- a/PHPCI/Plugin/Option/PhpUnitOptions.php +++ b/PHPCI/Plugin/Option/PhpUnitOptions.php @@ -96,13 +96,13 @@ class PhpUnitOptions $this->arguments = $rawArgs; } else { /* - * Try to parse old argument in a single string + * Try to parse old arguments in a single string */ - preg_match_all('/--([a-z\-]+)\s?("?[^-]{2}[^"]*"?)?/', (string)$rawArgs, $argsMatch); + preg_match_all('@--([a-z\-]+)([\s=]+)?[\'"]?((?!--)[-\w/.,\\\]+)?[\'"]?@', (string)$rawArgs, $argsMatch); if (!empty($argsMatch) && sizeof($argsMatch) > 2) { foreach ($argsMatch[1] as $index => $argName) { - $this->addArgument($argName, $argsMatch[2][$index]); + $this->addArgument($argName, $argsMatch[3][$index]); } } } diff --git a/PHPCI/Plugin/Util/PhpUnitResult.php b/PHPCI/Plugin/Util/PhpUnitResult.php index e359708e..3222f297 100644 --- a/PHPCI/Plugin/Util/PhpUnitResult.php +++ b/PHPCI/Plugin/Util/PhpUnitResult.php @@ -48,6 +48,9 @@ class PhpUnitResult public function parse() { $rawResults = file_get_contents($this->outputFile); + if (empty($rawResults)) { + throw new \Exception('No test executed.'); + } if ($rawResults[0] == '{') { $fixedJson = '[' . str_replace('}{', '},{', $rawResults) . ']'; $events = json_decode($fixedJson, true); diff --git a/Tests/PHPCI/Plugin/Option/PhpUnitOptionsTest.php b/Tests/PHPCI/Plugin/Option/PhpUnitOptionsTest.php index 8fd851c8..c5ce091a 100644 --- a/Tests/PHPCI/Plugin/Option/PhpUnitOptionsTest.php +++ b/Tests/PHPCI/Plugin/Option/PhpUnitOptionsTest.php @@ -61,6 +61,39 @@ class PhpUnitOptionsTest extends \PHPUnit_Framework_TestCase 'coverage-html' => '/path/to/coverage1/', ), ), + array( + array( + 'config' => array('tests/phpunit.xml'), + 'args' => "--testsuite=unit --bootstrap=vendor/autoload.php", + ), + array( + 'testsuite' => 'unit', + 'bootstrap' => 'vendor/autoload.php', + 'configuration' => array('tests/phpunit.xml'), + ), + ), + array( + array( + 'config' => array('tests/phpunit.xml'), + 'args' => "--testsuite='unit' --bootstrap 'vendor/autoload.php'", + ), + array( + 'testsuite' => 'unit', + 'bootstrap' => 'vendor/autoload.php', + 'configuration' => array('tests/phpunit.xml'), + ), + ), + array( + array( + 'config' => array('tests/phpunit.xml'), + 'args' => '--testsuite="unit" --bootstrap "vendor/autoload.php"', + ), + array( + 'testsuite' => 'unit', + 'bootstrap' => 'vendor/autoload.php', + 'configuration' => array('tests/phpunit.xml'), + ), + ), ); }