mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-56006 behat: Load proper context by helper
This commit is contained in:
parent
848db61636
commit
d87dac7e70
@ -44,12 +44,16 @@ class behat_context_helper {
|
||||
*/
|
||||
protected static $environment = null;
|
||||
|
||||
|
||||
/**
|
||||
* @var Escaper::escapeLiteral
|
||||
*/
|
||||
protected static $escaper;
|
||||
|
||||
/**
|
||||
* @var array keep track of nonexisting contexts, to avoid exception tracking.
|
||||
*/
|
||||
protected static $nonexistingcontexts = array();
|
||||
|
||||
/**
|
||||
* Sets the browser session.
|
||||
*
|
||||
@ -88,15 +92,21 @@ class behat_context_helper {
|
||||
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;
|
||||
|
||||
// Check if overridden context class exists.
|
||||
if ($suitename !== 'default') {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user