Пример #1
0
 /**
  * Gets the required context.
  *
  * Getting a context you get access to all the steps
  * that uses direct API calls; steps returning step chains
  * can not be executed like this.
  *
  * @throws Behat\Behat\Context\Exception\ContextNotFoundException
  * @param string $classname Context identifier (the class name).
  * @return behat_base
  */
 public static function get($classname)
 {
     $suitename = self::$environment->getSuite()->getName();
     $overridencontextname = 'behat_theme_' . $suitename . '_' . $classname;
     // Check if overridden context class exists.
     if ($suitename !== 'default') {
         try {
             $subcontext = self::$environment->getContext($overridencontextname);
             return $subcontext;
         } catch (Behat\Behat\Context\Exception\ContextNotFoundException $e) {
             // If context not found then it's not overridden.
         }
     }
     // Get the actual context.
     return self::$environment->getContext($classname);
 }
Пример #2
0
 /**
  * {@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;
 }
Пример #3
0
 /**
  * Gets the required context.
  *
  * Getting a context you get access to all the steps
  * that uses direct API calls; steps returning step chains
  * can not be executed like this.
  *
  * @throws Behat\Behat\Context\Exception\ContextNotFoundException
  * @param string $classname Context identifier (the class name).
  * @return behat_base
  */
 public static function get($classname)
 {
     $suitename = self::$environment->getSuite()->getName();
     // If default suite, then get the default theme name.
     if ($suitename == 'default') {
         $suitename = theme_config::DEFAULT_THEME;
     }
     $overridencontextname = 'behat_theme_' . $suitename . '_' . $classname;
     // If contexts has not been checked before and doesn't exist then just use core one.
     if (!isset(self::$nonexistingcontexts[$overridencontextname])) {
         try {
             $subcontext = self::$environment->getContext($overridencontextname);
             return $subcontext;
         } catch (Behat\Behat\Context\Exception\ContextNotFoundException $e) {
             // If context not found then it's not overridden.
             self::$nonexistingcontexts[$overridencontextname] = 1;
         }
     }
     // Get the actual context.
     return self::$environment->getContext($classname);
 }
Пример #4
0
 public function isolateEnvironment(Environment $environment, $method = null)
 {
     $instance = $this->createInstance($environment->getSuite(), $method);
     $environment = new SpecEnvironment($environment->getSuite(), $instance);
     return $environment;
 }
Пример #5
0
 /**
  * Returns hook suite.
  *
  * @return Suite
  */
 public function getSuite()
 {
     return $this->environment->getSuite();
 }