/** * A failure occurred. * * @param \PHPUnit_Framework_Test $test * @param \PHPUnit_Framework_AssertionFailedError $e * @param float $time */ public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) { if (!$this->colors) { parent::addFailure($test, $e, $time); return; } $this->writeProgress(Coloring::red('F')); $this->lastTestFailed = true; }
public function paintFooter($test_name) { ob_start(); parent::paintFooter($test_name); $output = ob_get_contents(); ob_end_clean(); if ($this->terminal->shouldColor()) { if ($this->getFailCount() + $this->getExceptionCount() == 0) { echo Coloring::green($output); } else { echo Coloring::red($output); } } else { echo $output; } if ($this->runner->shouldNotify()) { if ($this->getFailCount() + $this->getExceptionCount() == 0) { $notificationResult = Notification::RESULT_PASSED; } else { $notificationResult = Notification::RESULT_FAILED; } $this->notification = new Notification($notificationResult, $output); } }
/** * @param string $name * @param bool $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->terminal->shouldColor()) { switch ($testStatus) { case \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED: $name = Coloring::green($name); break; case \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR: $name = Coloring::magenta($name); break; case \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE: $name = Coloring::red($name); break; case \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE: case \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED: $name = Coloring::yellow($name); break; } } parent::onTest($name, $success); }
/** * A failure occurred. * * @param \PHPUnit_Framework_Test $test * @param \PHPUnit_Framework_AssertionFailedError $e * @param float $time */ public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) { $message = 'failed'; $this->write($this->colors ? Coloring::red($message) : $message); parent::addFailure($test, $e, $time); }