public function PHPUnit_TextUI_Command::run in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/phpunit/phpunit/src/TextUI/Command.php \PHPUnit_TextUI_Command::run()
Parameters
array $argv:
bool $exit:
Return value
int
File
- vendor/
phpunit/ phpunit/ src/ TextUI/ Command.php, line 108
Class
- PHPUnit_TextUI_Command
- A TestRunner for the Command Line Interface (CLI) PHP SAPI Module.
Code
public function run(array $argv, $exit = true) {
$this
->handleArguments($argv);
$runner = $this
->createRunner();
if (is_object($this->arguments['test']) && $this->arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $this->arguments['test'];
}
else {
$suite = $runner
->getTest($this->arguments['test'], $this->arguments['testFile'], $this->arguments['testSuffixes']);
}
if ($this->arguments['listGroups']) {
$this
->printVersionString();
print "Available test group(s):\n";
$groups = $suite
->getGroups();
sort($groups);
foreach ($groups as $group) {
print " - {$group}\n";
}
if ($exit) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
else {
return PHPUnit_TextUI_TestRunner::SUCCESS_EXIT;
}
}
unset($this->arguments['test']);
unset($this->arguments['testFile']);
try {
$result = $runner
->doRun($suite, $this->arguments);
} catch (PHPUnit_Framework_Exception $e) {
print $e
->getMessage() . "\n";
}
$ret = PHPUnit_TextUI_TestRunner::FAILURE_EXIT;
if (isset($result) && $result
->wasSuccessful()) {
$ret = PHPUnit_TextUI_TestRunner::SUCCESS_EXIT;
}
elseif (!isset($result) || $result
->errorCount() > 0) {
$ret = PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT;
}
if ($exit) {
exit($ret);
}
else {
return $ret;
}
}