Exemplo n.º 1
0
 /**
  * Get the actual summary string.
  *
  * @return string
  */
 public function __toString()
 {
     $message = sprintf("%s %s", $this->icons[$this->result->getStatus()], $this->result->getMessage());
     $color = $this->colors[$this->result->getStatus()];
     $terminal = $this->result->getTerminal();
     return $terminal->token("[{$color['set']}m") . $message . $terminal->token("[{$color['unset']}m") . PHP_EOL;
 }
Exemplo n.º 2
0
 /**
  * Create a new Result object that can be used when writing tasks.
  *
  * @param array $options
  * @return Result
  */
 public function result(array $options = array())
 {
     $result = new Result($options);
     $result->setTerminal($this->terminal);
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Render the output generated by phpcs and set the result status according
  * to whether any warnings or errors were generated.
  *
  * @param Result $result
  * @param array $phpcsOutput
  * @return Result
  */
 private function handlePhpcsResults(Result $result, array $phpcsOutput)
 {
     if (!$phpcsOutput['totals']['errors'] && !$phpcsOutput['totals']['warnings']) {
         $result->setStatus(Result::SUCCESS)->setMessage('PHP_CodeSniffer found no errors.');
     } else {
         $output = array();
         foreach ($phpcsOutput['files'] as $file => $results) {
             if (count($results['messages'])) {
                 $output[] = $file;
                 $output[] = str_repeat('-', strlen($file));
                 $output[] = '';
                 foreach ($results['messages'] as $message) {
                     $output[] = sprintf('%s: %s (Line %d, Column %d)', $message['type'], $message['message'], $message['line'], $message['column']);
                 }
                 $output[] = '';
             }
         }
         $result->setOutput($output);
         if ($phpcsOutput['totals']['errors']) {
             $result->setStatus(Result::FAIL)->setMessage("PHP_CodeSniffer generated {$phpcsOutput['totals']['errors']} errors.");
         } elseif ($phpcsOutput['totals']['warnings']) {
             $result->setStatus(Result::WARN)->setMessage("PHP_CodeSniffer generated {$phpcsOutput['totals']['warnings']} warnings.");
         }
     }
     return $result;
 }
Exemplo n.º 4
0
 public function testAllResultsSucceedingMakesIsFailureReturnFalse()
 {
     $one = new Result();
     $one->setMessage('RESULT_ONE')->setStatus(Result::SUCCESS);
     $two = new Result();
     $two->setMessage('RESULT_TWO')->setStatus(Result::SUCCESS);
     $this->result->addResult($one);
     $this->result->addResult($two);
     $this->assertFalse($this->result->isFailure());
 }