Author: Konstantin Kudryashov (ever.zet@gmail.com)
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function guessTargetContextClass(ContextEnvironment $environment)
 {
     $suiteKey = $environment->getSuite()->getName();
     if (array_key_exists($suiteKey, $this->contextClasses)) {
         return $this->contextClasses[$suiteKey];
     }
     return $this->contextClasses[$suiteKey] = $this->decoratedIdentifier->guessTargetContextClass($environment);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function generateSnippet(Environment $environment, StepNode $step)
 {
     if (!$environment instanceof ContextEnvironment) {
         throw new EnvironmentSnippetGenerationException(sprintf('ContextSnippetGenerator does not support `%s` environment.', get_class($environment)), $environment);
     }
     $contextClass = $this->contextIdentifier->guessTargetContextClass($environment);
     $patternType = $this->patternIdentifier->guessPatternType($contextClass);
     $stepText = $step->getText();
     $pattern = $this->patternTransformer->generatePattern($patternType, $stepText);
     $methodName = $this->getMethodName($contextClass, $pattern->getCanonicalText(), $pattern->getPattern());
     $methodArguments = $this->getMethodArguments($step, $pattern->getPlaceholderCount());
     $snippetTemplate = $this->getSnippetTemplate($pattern->getPattern(), $methodName, $methodArguments);
     $usedClasses = $this->getUsedClasses($step);
     return new ContextSnippet($step, $snippetTemplate, $contextClass, $usedClasses);
 }