/** * 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 coding_exception * @param string $classname Context identifier (the class name). * @return behat_base */ public static function get($classname) { if (!($subcontext = self::$environment->getContext($classname))) { throw coding_exception('The required "' . $classname . '" class does not exist'); } return $subcontext; }
/** * 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); }
/** * 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); }