Ejemplo n.º 1
0
 public function testIsSuccessful()
 {
     $request = new RequestFailure(new ArrayObject(), 'EXPECTED', 'ACTUAL');
     $cliResult = new CliResult([$request]);
     $this->assertFalse($cliResult->isSuccessful());
     $cliResult = new CliResult([new Success(new ArrayObject())]);
     $this->assertTrue($cliResult->isSuccessful());
     $cliResult->add($request);
     $this->assertFalse($cliResult->isSuccessful());
 }
 public function testIsSuccessfulWithResultGroups()
 {
     $resultAggregator = new ResultAggregator();
     $this->assertTrue($resultAggregator->isSuccessful());
     $resultGroup = new CliResult();
     $resultGroup->add(new CliSuccess(new ArrayObject()));
     $resultAggregator->add($resultGroup);
     $this->assertTrue($resultAggregator->isSuccessful());
     $resultGroup->add(new CliGenericFailure(new ArrayObject(), 'nop'));
     $this->assertFalse($resultAggregator->isSuccessful());
 }
Ejemplo n.º 3
0
 /**
  * Render the details of each failed request including the mismatching headers and body.
  *
  * @param ResultsRenderer $renderer
  * @return string
  */
 public function render(ResultsRenderer $renderer)
 {
     $results = array_filter($this->result->getResults(), function (ResultInterface $result) {
         return $result instanceof FailureInterface;
     });
     $output = '';
     if (count($results)) {
         $output .= $renderer->center("Some executions of your solution produced incorrect output!\n");
     }
     /** @var FailureInterface $request **/
     foreach ($results as $key => $request) {
         $output .= $renderer->lineBreak();
         $output .= "\n";
         $output .= $renderer->style(sprintf('Execution %d', $key + 1), ['bold', 'underline', 'blue']);
         $output .= ' ' . $renderer->style(' FAILED ', ['bg_red', 'bold']) . "\n\n";
         $output .= $request->getArgs()->isEmpty() ? "Arguments: None\n" : sprintf("Arguments: \"%s\"\n", $request->getArgs()->implode('", "'));
         $output .= "\n" . $renderer->renderResult($request) . "\n";
     }
     return $output;
 }