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. 2
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));
 }