/**
  * {@inheritdoc}
  *
  * @throws AmbiguousMatchException
  */
 public function searchDefinition(Environment $environment, FeatureNode $feature, StepNode $step)
 {
     $suite = $environment->getSuite();
     $language = $feature->getLanguage();
     $stepText = $step->getText();
     $multi = $step->getArguments();
     $definitions = array();
     $result = null;
     foreach ($this->repository->getEnvironmentDefinitions($environment) as $definition) {
         $definition = $this->translator->translateDefinition($suite, $definition, $language);
         if (!($newResult = $this->match($definition, $stepText, $multi))) {
             continue;
         }
         $result = $newResult;
         $definitions[] = $newResult->getMatchedDefinition();
     }
     if (count($definitions) > 1) {
         throw new AmbiguousMatchException($result->getMatchedText(), $definitions);
     }
     return $result;
 }
Example #2
0
 /**
  * Prints definitions for provided suite using printer.
  *
  * @param DefinitionPrinter $printer
  * @param Suite             $suite
  */
 public function printSuiteDefinitions(DefinitionPrinter $printer, $suite)
 {
     $environment = $this->environmentManager->buildEnvironment($suite);
     $definitions = $this->repository->getEnvironmentDefinitions($environment);
     $printer->printDefinitions($suite, $definitions);
 }