/**
  * Prints feature title using provided printer.
  *
  * @param OutputPrinter $printer
  * @param FeatureNode   $feature
  */
 private function printTitle(OutputPrinter $printer, FeatureNode $feature)
 {
     $printer->write(sprintf('%s{+keyword}%s:{-keyword}', $this->indentText, $feature->getKeyword()));
     if ($title = $feature->getTitle()) {
         $printer->write(sprintf(' %s', $title));
     }
     $printer->writeln();
 }
Beispiel #2
0
 /**
  * Prints scenario and step counters.
  *
  * @param OutputPrinter $printer
  * @param string        $intro
  * @param array         $stats
  */
 public function printCounters(OutputPrinter $printer, $intro, array $stats)
 {
     $stats = array_filter($stats, function ($count) {
         return 0 !== $count;
     });
     if (0 === count($stats)) {
         $totalCount = 0;
     } else {
         $totalCount = array_sum($stats);
     }
     $detailedStats = array();
     foreach ($stats as $resultCode => $count) {
         $style = $this->resultConverter->convertResultCodeToString($resultCode);
         $transId = $style . '_count';
         $message = $this->translator->transChoice($transId, $count, array('%1%' => $count), 'output');
         $detailedStats[] = sprintf('{+%s}%s{-%s}', $style, $message, $style);
     }
     $message = $this->translator->transChoice($intro, $totalCount, array('%1%' => $totalCount), 'output');
     $printer->write($message);
     if (count($detailedStats)) {
         $printer->write(sprintf(' (%s)', implode(', ', $detailedStats)));
     }
     $printer->writeln();
 }
 /**
  * Triggers after running tests.
  *
  * @param TestworkEvent\AfterExerciseCompleted $event
  */
 public function onAfterExercise(TestworkEvent\AfterExerciseCompleted $event)
 {
     $this->timer->stop();
     $this->renderer->render();
     $this->printer->write($this->renderer->getResult());
 }
 /**
  * Prints step text.
  *
  * @param OutputPrinter $printer
  * @param string        $stepType
  * @param string        $stepText
  * @param StepResult    $result
  */
 private function printText(OutputPrinter $printer, $stepType, $stepText, StepResult $result)
 {
     $style = $this->resultConverter->convertResultCodeToString(TestResult::SKIPPED);
     if ($result instanceof DefinedStepResult && $result->getStepDefinition()) {
         $definition = $result->getStepDefinition();
         $stepText = $this->textPainter->paintText($stepText, $definition, new IntegerTestResult(TestResult::SKIPPED));
     }
     $printer->write(sprintf('%s{+%s}%s %s{-%s}', $this->indentText, $style, $stepType, $stepText, $style));
 }
 /**
  * Prints scenario title (first line of long title).
  *
  * @param OutputPrinter $printer
  * @param string        $longTitle
  */
 private function printTitle(OutputPrinter $printer, $longTitle)
 {
     $description = explode("\n", $longTitle);
     $title = array_shift($description);
     if ('' !== $title) {
         $printer->write(sprintf(' %s', $title));
     }
 }
 /**
  * Prints example title.
  *
  * @param OutputPrinter $printer
  * @param ExampleNode   $example
  */
 private function printTitle(OutputPrinter $printer, ExampleNode $example)
 {
     $printer->write(sprintf('%s%s', $this->indentText, $example->getTitle()));
 }