/** * {@inheritdoc} */ public function guessTargetContextClass(ContextEnvironment $environment) { if ($environment->hasContextClass($this->contextClass)) { return $this->contextClass; } return null; }
/** * {@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); }
/** * {@inheritdoc} */ public function guessTargetContextClass(ContextEnvironment $environment) { foreach ($environment->getContextClasses() as $class) { if (in_array('Behat\\Behat\\Context\\SnippetAcceptingContext', class_implements($class))) { return $class; } } return null; }
/** * {@inheritdoc} * * @see TranslatableContext */ public function readContextCallees(ContextEnvironment $environment, $contextClass) { $reflClass = new \ReflectionClass($contextClass); if (!$reflClass->implementsInterface('Behat\\Behat\\Context\\TranslatableContext')) { return array(); } $assetsId = $environment->getSuite()->getName(); foreach (call_user_func(array($contextClass, 'getTranslationResources')) as $path) { $this->addTranslationResource($path, $assetsId); } return array(); }
/** * {@inheritdoc} */ public function guessTargetContextClass(ContextEnvironment $environment) { if ($this->interactionIsNotSupported()) { return null; } $suiteName = $environment->getSuite()->getName(); $contextClasses = $environment->getContextClasses(); if (!count($contextClasses)) { return null; } $message = $this->translator->trans('snippet_context_choice', array('%1%' => $suiteName), 'output'); $choices = array_values(array_merge(array('None'), $contextClasses)); $default = current($contextClasses); $answer = $this->askQuestion('>> ' . $message, $choices, $default); return 'None' !== $answer ? $answer : null; }
/** * Generates cache key. * * @param ContextEnvironment $environment * @param string $contextClass * * @return string */ private function generateCacheKey(ContextEnvironment $environment, $contextClass) { return $environment->getSuite()->getName() . $contextClass; }