PHPUnit_Util_TestDox_ResultPrinter_Text::onTest PHP Method

onTest() protected method

Handler for 'on test' event.
protected onTest ( string $name, boolean $success = TRUE )
$name string
$success boolean
    protected function onTest($name, $success = TRUE)
    {
        if ($success) {
            $this->write(' [x] ');
        } else {
            $this->write(' [ ] ');
        }
        $this->write($name . "\n");
    }

Usage Example

 /**
  * @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);
 }
PHPUnit_Util_TestDox_ResultPrinter_Text