Example #1
0
 /**
  * Initializes redundant exception.
  *
  * @param   Behat\Behat\Definition\Definition   $step2    duplicate step definition
  * @param   Behat\Behat\Definition\Definition   $step1    firstly matched step definition
  */
 public function __construct(Definition $step2, Definition $step1)
 {
     $message = sprintf("Step \"%s\" is already defined in %s:%d\n\n%s:%d\n%s:%d", $step2->getRegex(), $step1->getFile(), $step1->getLine(), $step1->getFile(), $step1->getLine(), $step2->getFile(), $step2->getLine());
     parent::__construct($message);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function printStepDefinitionPath(StepNode $step, Definition $definition)
 {
     $this->printPathComment($definition->getFile(), $definition->getLine());
 }
Example #3
0
 /**
  * Prints path to step.
  *
  * @param   Behat\Gherkin\Node\StepNode         $step           step node
  * @param   Behat\Behat\Definition\Definition   $definition     definition (if step defined)
  * @param   Exception                           $exception      exception (if step failed)
  */
 protected function printStepPath(StepNode $step, Definition $definition = null, \Exception $exception = null)
 {
     $color = $exception instanceof Pending ? 'pending' : 'failed';
     $type = $step->getType();
     $text = $step->getText();
     $stepPath = "In step `{$type} {$text}'.";
     $stepPathLn = mb_strlen($stepPath);
     $node = $step->getParent();
     if ($node instanceof BackgroundNode) {
         $scenarioPath = "From scenario background.";
     } else {
         $title = $node->getTitle();
         $title = $title ? "`{$title}'" : '***';
         $scenarioPath = "From scenario {$title}.";
     }
     $scenarioPathLn = mb_strlen($scenarioPath);
     $this->maxLineLength = max($this->maxLineLength, $stepPathLn);
     $this->maxLineLength = max($this->maxLineLength, $scenarioPathLn);
     $this->write("    {+{$color}}{$stepPath}{-{$color}}");
     if (null !== $definition) {
         $indentCount = $this->maxLineLength - $stepPathLn;
         $this->printPathComment($definition->getFile(), $definition->getLine(), $indentCount);
     } else {
         $this->writeln();
     }
     $this->write("    {+{$color}}{$scenarioPath}{-{$color}}");
     $indentCount = $this->maxLineLength - $scenarioPathLn;
     $this->printPathComment($node->getFile(), $node->getLine(), $indentCount);
     $this->writeln();
 }
Example #4
0
 /**
  * Prints step definition path.
  *
  * @param   Behat\Gherkin\Node\StepNode         $step       step node
  * @param   Behat\Behat\Definition\Definition   $definition definition (if found one)
  *
  * @uses    printPathComment()
  */
 protected function printStepDefinitionPath(StepNode $step, Definition $definition)
 {
     $type = $step->getType();
     $text = $this->inOutlineSteps ? $step->getCleanText() : $step->getText();
     $nameLength = mb_strlen("    {$type} {$text}");
     $indentCount = $nameLength > $this->maxLineLength ? 0 : $this->maxLineLength - $nameLength;
     $this->printPathComment($definition->getFile(), $definition->getLine(), $indentCount);
 }