/** * Prints step definition path. * * @param StepNode $step step node * @param DefinitionInterface $definition definition (if found one) * * @uses printPathComment() */ protected function printStepDefinitionPath(StepNode $step, DefinitionInterface $definition) { if ($this->getParameter('paths')) { $type = $step->getType(); $text = $this->inOutlineSteps ? $step->getCleanText() : $step->getText(); $indent = $this->stepIndent; $nameLength = mb_strlen("{$indent}{$type} {$text}"); $indentCount = $nameLength > $this->maxLineLength ? 0 : $this->maxLineLength - $nameLength; $this->printPathComment($this->relativizePathsInString($definition->getPath()), $indentCount); if ($this->getParameter('expand')) { $this->maxLineLength = max($this->maxLineLength, $nameLength); } } else { $this->writeln(); } }
/** * Prints path link, which links to the source containing the step definition. * * @param DefinitionInterface $definition */ protected function printPathLink(DefinitionInterface $definition) { $url = $this->getParameter('paths_base_url') . $this->relativizePathsInString($definition->getCallbackReflection()->getFileName()); $path = $this->relativizePathsInString($definition->getPath()); $this->writeln('<span class="path"><a href="' . $url . '">' . $path . '</a></span>'); }
/** * {@inheritdoc} */ protected function printStepDefinitionPath(StepNode $step, DefinitionInterface $definition) { if ($this->getParameter('paths')) { $this->printPathComment($this->relativizePathsInString($definition->getPath())); } }
/** * Initializes redundant exception. * * @param DefinitionInterface $step2 duplicate step definition * @param DefinitionInterface $step1 firstly matched step definition */ public function __construct(DefinitionInterface $step2, DefinitionInterface $step1) { $message = sprintf("Step \"%s\" is already defined in %s\n\n%s\n%s", $step2->getRegex(), $step1->getPath(), $step1->getPath(), $step2->getPath()); parent::__construct($message); }
/** * Prints path to step. * * @param StepNode $step step node * @param DefinitionInterface $definition definition (if step defined) * @param \Exception $exception exception (if step failed) */ protected function printStepPath(StepNode $step, DefinitionInterface $definition = null, \Exception $exception = null) { $color = $exception instanceof PendingException ? '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); $feature = $node->getFeature(); $title = $feature->getTitle(); $title = $title ? "`{$title}'" : '***'; $featurePath = "Of feature {$title}."; $featurePathLn = mb_strlen($featurePath); $this->maxLineLength = max($this->maxLineLength, $stepPathLn); $this->maxLineLength = max($this->maxLineLength, $scenarioPathLn); $this->maxLineLength = max($this->maxLineLength, $featurePathLn); $this->write(" {+{$color}}{$stepPath}{-{$color}}"); if (null !== $definition) { $indentCount = $this->maxLineLength - $stepPathLn; $this->printPathComment($this->relativizePathsInString($definition->getPath()), $indentCount); } else { $this->writeln(); } $this->write(" {+{$color}}{$scenarioPath}{-{$color}}"); $indentCount = $this->maxLineLength - $scenarioPathLn; $this->printPathComment($this->relativizePathsInString($node->getFile()) . ':' . $node->getLine(), $indentCount); $this->write(" {+{$color}}{$featurePath}{-{$color}}"); $indentCount = $this->maxLineLength - $featurePathLn; $this->printPathComment($this->relativizePathsInString($feature->getFile()), $indentCount); $this->writeln(); }