Ejemplo n.º 1
0
 public function onFinish(RunEvent $e)
 {
     /* @var $results \ZFTool\Diagnostics\Result\Collection */
     $results = $e->getResults();
     // Display information that the test has been aborted.
     if ($this->stopped) {
         $this->console->writeLine('Diagnostics aborted because of a failure.', Color::RED);
     }
     // Display a summary line
     if ($results->getFailureCount() == 0 && $results->getWarningCount() == 0 && $results->getUnknownCount() == 0) {
         $this->console->write('  OK  ', Color::NORMAL, Color::GREEN);
         $this->console->write(' ');
         $this->console->writeLine(str_pad(' (' . $this->total . ' diagnostic tests)', $this->width - 8, ' ', STR_PAD_RIGHT), Color::NORMAL, Color::GREEN);
     } elseif ($results->getFailureCount() == 0) {
         $line = ' (' . $results->getWarningCount() . ' warnings, ';
         $line .= $results->getSuccessCount() . ' successful tests';
         if ($results->getUnknownCount() > 0) {
             $line .= ', ' . $results->getUnknownCount() . ' unknown test results';
         }
         $line .= ')';
         $this->console->write(' WARN ', Color::NORMAL, Color::YELLOW);
         $this->console->write(' ');
         $this->console->writeLine(str_pad($line, $this->width - 8, ' ', STR_PAD_RIGHT), Color::NORMAL, Color::YELLOW);
     } else {
         $line = ' (' . $results->getFailureCount() . ' failures, ';
         $line .= $results->getWarningCount() . ' warnings, ';
         $line .= $results->getSuccessCount() . ' successful tests';
         if ($results->getUnknownCount() > 0) {
             $line .= ', ' . $results->getUnknownCount() . ' unknown test results';
         }
         $line .= ')';
         $this->console->write(' FAIL ', Color::NORMAL, Color::RED);
         $this->console->write(' ');
         $this->console->writeLine(str_pad($line, $this->width - 8, ' ', STR_PAD_RIGHT), Color::NORMAL, Color::RED);
     }
     $this->console->writeLine();
 }
Ejemplo n.º 2
0
 public function onFinish(RunEvent $e)
 {
     /* @var $results \ZFTool\Diagnostics\Result\Collection */
     $results = $e->getResults();
     $this->console->writeLine();
     $this->console->writeLine();
     // Display a summary line
     if ($results->getFailureCount() == 0 && $results->getWarningCount() == 0 && $results->getUnknownCount() == 0) {
         $this->console->write('  OK  ', Color::NORMAL, Color::GREEN);
         $this->console->write(' ');
         $this->console->writeLine(str_pad(' (' . $this->total . ' diagnostic tests)', $this->width - 8, ' ', STR_PAD_RIGHT), Color::NORMAL, Color::GREEN);
     } elseif ($results->getFailureCount() == 0) {
         $line = ' (' . $results->getWarningCount() . ' warnings, ';
         $line .= $results->getSuccessCount() . ' successful tests';
         if ($results->getUnknownCount() > 0) {
             $line .= ', ' . $results->getUnknownCount() . ' unknown test results';
         }
         $line .= ')';
         $this->console->write(' WARN ', Color::NORMAL, Color::YELLOW);
         $this->console->write(' ');
         $this->console->writeLine(str_pad($line, $this->width - 8, ' ', STR_PAD_RIGHT), Color::NORMAL, Color::YELLOW);
     } else {
         $line = ' (' . $results->getFailureCount() . ' failures, ';
         $line .= $results->getWarningCount() . ' warnings, ';
         $line .= $results->getSuccessCount() . ' successful tests';
         if ($results->getUnknownCount() > 0) {
             $line .= ', ' . $results->getUnknownCount() . ' unknown test results';
         }
         $line .= ')';
         $this->console->write(' FAIL ', Color::NORMAL, Color::RED);
         $this->console->write(' ');
         $this->console->writeLine(str_pad($line, $this->width - 8, ' ', STR_PAD_RIGHT), Color::NORMAL, Color::RED);
     }
     $this->console->writeLine();
     // Display a list of failures and warnings
     foreach ($results as $test) {
         /* @var $test \ZFTool\Diagnostics\Test\TestInterface */
         /* @var $result \ZFTool\Diagnostics\Result\ResultInterface */
         $result = $results[$test];
         if ($result instanceof Failure) {
             $this->console->writeLine('       Failure: ' . $test->getLabel(), Color::RED);
             $message = $result->getMessage();
             if ($message) {
                 $this->console->writeLine('       => ' . $message, Color::RED);
             }
             $this->console->writeLine();
         } elseif ($result instanceof Warning) {
             $this->console->writeLine('       Warning: ' . $test->getLabel(), Color::YELLOW);
             $message = $result->getMessage();
             if ($message) {
                 $this->console->writeLine('       => ' . $message, Color::YELLOW);
             }
             $this->console->writeLine();
         } elseif (!$result instanceof Success) {
             $this->console->writeLine('       Unknown result ' . get_class($result) . ': ' . $test->getLabel(), Color::YELLOW);
             $message = $result->getMessage();
             if ($message) {
                 $this->console->writeLine('       => ' . $message, Color::YELLOW);
             }
             $this->console->writeLine();
         }
     }
     // Display information that the test has been aborted.
     if ($this->stopped) {
         $this->console->write(' STOP ', Color::NORMAL, Color::RED);
         $this->console->write(' ');
         $this->console->writeLine('Diagnostics aborted because of a failure.', Color::RED);
         $this->console->writeLine();
     }
 }