Example #1
0
 /**
  * Gets totals to print
  * 
  * @return string
  */
 protected function getTotals()
 {
     $failures = $this->_reporter->getFailures()->count();
     $errors = $this->_reporter->getErrors()->count();
     $pending = $this->_reporter->getPendingExamples()->count();
     $exceptions = $this->_reporter->getExceptions()->count();
     $passing = count($this->_reporter->getPassing());
     $total = $failures + $errors + $pending + $exceptions + $passing;
     if ($failures + $errors + $pending + $exceptions > 0) {
         $this->_errorOnExit = true;
     }
     $totals = "{$total} example" . ($total !== 1 ? "s" : "");
     if ($failures) {
         $plural = $failures !== 1 ? "s" : "";
         $totals .= ", {$failures} failure{$plural}";
     }
     if ($errors) {
         $plural = $errors !== 1 ? "s" : "";
         $totals .= ", {$errors} error{$plural}";
     }
     if ($exceptions) {
         $plural = $exceptions !== 1 ? "s" : "";
         $totals .= ", {$exceptions} exception{$plural}";
     }
     if ($pending) {
         $plural = $pending !== 1 ? "s" : "";
         $totals .= ", {$pending} pending{$plural}";
     }
     if ($failures || $errors || $exceptions) {
         $totals = $this->red($totals);
     } elseif ($pending) {
         $totals = $this->yellow($totals);
     } elseif ($passing) {
         $totals = $this->green($totals);
     }
     return $totals;
 }