/**
  * {@inheritdoc}
  */
 public function printHeader(Formatter $formatter, FeatureNode $feature, Scenario $scenario)
 {
     if ($scenario instanceof TaggedNodeInterface) {
         $this->printTags($formatter->getOutputPrinter(), $scenario->getTags());
     }
     $this->printKeyword($formatter->getOutputPrinter(), $scenario->getKeyword());
     $this->printTitle($formatter->getOutputPrinter(), $scenario->getTitle());
     $this->pathPrinter->printScenarioPath($formatter, $feature, $scenario, mb_strlen($this->indentText, 'utf8'));
     $this->printDescription($formatter->getOutputPrinter(), $scenario->getTitle());
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function printOpenTag(Formatter $formatter, FeatureNode $feature, ScenarioLikeInterface $scenario, TestResult $result)
 {
     $name = implode(' ', array_map(function ($l) {
         return trim($l);
     }, explode("\n", $scenario->getTitle())));
     if ($scenario instanceof ExampleNode) {
         $name = $this->buildExampleName();
     }
     /** @var JUnitOutputPrinter $outputPrinter */
     $outputPrinter = $formatter->getOutputPrinter();
     $outputPrinter->addTestcase(array('name' => $name, 'status' => $this->resultConverter->convertResultToString($result)));
 }
 function its_printHeader_when_basePath_is_specified_should_output_file_and_line_with_relative_path(Formatter $formatter, FeatureNode $featureNode, Scenario $scenario, OutputPrinter $printer)
 {
     $folderName = 'foldername';
     $filename = 'file';
     $lineNumber = 2;
     $this->beConstructedWith($folderName);
     $formatter->getOutputPrinter()->shouldBeCalled()->willReturn($printer);
     $featureNode->getFile()->shouldBeCalled()->willReturn($folderName . '/' . $filename);
     $scenario->getLine()->shouldBeCalled()->willReturn($lineNumber);
     $printer->write("{$filename}:{$lineNumber}")->shouldBeCalled();
     $this->printHeader($formatter, $featureNode, $scenario);
 }
Esempio n. 4
0
 /**
  * Calculates scenario header width.
  *
  * @param Scenario $scenario
  * @param integer  $indentation
  *
  * @return integer
  */
 public function calculateScenarioHeaderWidth(Scenario $scenario, $indentation)
 {
     $indentText = str_repeat(' ', intval($indentation));
     if ($scenario instanceof ExampleNode) {
         $header = sprintf('%s%s', $indentText, $scenario->getTitle());
     } else {
         $title = $scenario->getTitle();
         $lines = explode("\n", $title);
         $header = sprintf('%s%s: %s', $indentText, $scenario->getKeyword(), array_shift($lines));
     }
     return mb_strlen(rtrim($header), 'utf8');
 }
Esempio n. 5
0
 /**
  * Prints scenario path comment.
  *
  * @param Formatter   $formatter
  * @param FeatureNode $feature
  * @param Scenario    $scenario
  * @param integer     $indentation
  */
 public function printScenarioPath(Formatter $formatter, FeatureNode $feature, Scenario $scenario, $indentation)
 {
     $printer = $formatter->getOutputPrinter();
     if (!$formatter->getParameter('paths')) {
         $printer->writeln();
         return;
     }
     $fileAndLine = sprintf('%s:%s', $this->relativizePaths($feature->getFile()), $scenario->getLine());
     $headerWidth = $this->widthCalculator->calculateScenarioHeaderWidth($scenario, $indentation);
     $scenarioWidth = $this->widthCalculator->calculateScenarioWidth($scenario, $indentation, 2);
     $spacing = str_repeat(' ', max(0, $scenarioWidth - $headerWidth));
     $printer->writeln(sprintf('%s {+comment}# %s{-comment}', $spacing, $fileAndLine));
 }
 /**
  * {@inheritdoc}
  */
 public function printHeader(Formatter $formatter, FeatureNode $feature, Scenario $scenario)
 {
     $printer = $formatter->getOutputPrinter();
     $fileAndLine = sprintf('%s:%s', $this->relativePath($feature->getFile()), $scenario->getLine());
     $printer->write(sprintf('%s', $fileAndLine));
 }