/** * An error occurred. * * @param PHPUnit_Framework_Test $test * @param Exception $e * @param float $time */ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { if (!$this->colors) { parent::addError($test, $e, $time); return; } $this->writeProgress(Stagehand_TestRunner_Coloring::magenta('E')); $this->lastTestFailed = TRUE; }
/** * @param string $name * @param boolean $success * @since Method available since Release 2.7.0 */ protected function onTest($name, $success = true) { if (!strlen($name)) { return; } $testStatus = $this->testStatuses[$name]; if ($this->testStatuses[$name] == PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE || $this->testStatuses[$name] == PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED) { if (strlen($this->testStatusMessages[$name])) { $name = $name . ' (' . str_replace(array("\r", "\n"), '', $this->testStatusMessages[$name]) . ')'; } } if ($this->colors) { switch ($testStatus) { case PHPUnit_Runner_BaseTestRunner::STATUS_PASSED: $name = Stagehand_TestRunner_Coloring::green($name); break; case PHPUnit_Runner_BaseTestRunner::STATUS_ERROR: $name = Stagehand_TestRunner_Coloring::magenta($name); break; case PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE: $name = Stagehand_TestRunner_Coloring::red($name); break; case PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE: case PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED: $name = Stagehand_TestRunner_Coloring::yellow($name); break; } } parent::onTest($name, $success); }
/** * An error occurred. * * @param PHPUnit_Framework_Test $test * @param Exception $e * @param float $time */ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { $message = 'raised an error'; $this->write($this->colors ? Stagehand_TestRunner_Coloring::magenta($message) : $message); parent::addError($test, $e, $time); }
/** * @param boolean $specs */ public function output($specs = false) { $output = preg_replace(array('/(\\x0d|\\x0a|\\x0d\\x0a){3,}/', '/^( -)(.+)/m'), array("\n\n", '$1 $2'), $this->toString($specs)); if ($this->color) { $failuresCount = $this->_result->countFailures(); $deliberateFailuresCount = $this->_result->countDeliberateFailures(); $errorsCount = $this->_result->countErrors(); $exceptionsCount = $this->_result->countExceptions(); $pendingsCount = $this->_result->countPending(); if ($failuresCount + $deliberateFailuresCount + $errorsCount + $exceptionsCount + $pendingsCount == 0) { $colorLabel = 'green'; } elseif ($pendingsCount && $failuresCount + $deliberateFailuresCount + $errorsCount + $exceptionsCount == 0) { $colorLabel = 'yellow'; } else { $colorLabel = 'red'; } $oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT); $output = preg_replace(array('/^(\\d+ examples?.*)/m', '/^( -)(.+)( \\(ERROR|EXCEPTION\\))/m', '/^( -)(.+)( \\(FAIL\\))/m', '/^( -)(.+)( \\(DELIBERATEFAIL\\))/m', '/^( -)(.+)( \\(PENDING\\))/m', '/^( -)(.+)/m', '/(\\d+\\)\\s+)(.+ (?:ERROR|EXCEPTION)\\s+.+)/', '/(\\d+\\)\\s+)(.+ FAILED\\s+.+)/', '/(\\d+\\)\\s+)(.+ PENDING\\s+.+)/', '/^((?:Errors|Exceptions):)/m', '/^(Failures:)/m', '/^(Pending:)/m'), array(Stagehand_TestRunner_Coloring::$colorLabel('$1'), Stagehand_TestRunner_Coloring::magenta('$1$2$3'), Stagehand_TestRunner_Coloring::red('$1$2$3'), Stagehand_TestRunner_Coloring::red('$1$2$3'), Stagehand_TestRunner_Coloring::yellow('$1$2$3'), Stagehand_TestRunner_Coloring::green('$1$2$3'), '$1' . Stagehand_TestRunner_Coloring::magenta('$2'), '$1' . Stagehand_TestRunner_Coloring::red('$2'), '$1' . Stagehand_TestRunner_Coloring::yellow('$2'), Stagehand_TestRunner_Coloring::magenta('$1'), Stagehand_TestRunner_Coloring::red('$1'), Stagehand_TestRunner_Coloring::yellow('$1')), Console_Color::escape($output)); error_reporting($oldErrorReportingLevel); } print $output; }