Exemple #1
0
 /**
  * @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);
 }
 /**
  * A test ended.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if (!$this->lastTestFailed) {
         $message = 'passed';
         $this->write($this->colors ? Stagehand_TestRunner_Coloring::green($message) : $message);
     }
     parent::endTest($test, $time);
     $this->lastEvent = PHPUnit_TextUI_ResultPrinter::EVENT_TEST_END;
 }
 /**
  * A test ended.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if (!$this->lastTestFailed) {
         $message = 'passed';
         $this->write($this->colors ? Stagehand_TestRunner_Coloring::green($message) : $message);
     }
     parent::endTest($test, $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;
 }
Exemple #5
0
 /**
  * A test ended.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if (!$this->colors) {
         parent::endTest($test, $time);
         return;
     }
     if (!$this->lastTestFailed) {
         $this->writeProgress(Stagehand_TestRunner_Coloring::green('.'));
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $this->numAssertions += $test->getNumAssertions();
     }
     $this->lastEvent = self::EVENT_TEST_END;
     $this->lastTestFailed = false;
 }