예제 #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);
 }
 /**
  * {@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();
 }
예제 #3
0
 /**
  * {@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;
 }