diff --git a/lib/behat/classes/behat_context_helper.php b/lib/behat/classes/behat_context_helper.php index 76851230042..399a3a9b6b7 100644 --- a/lib/behat/classes/behat_context_helper.php +++ b/lib/behat/classes/behat_context_helper.php @@ -148,6 +148,23 @@ class behat_context_helper { return $overrideclassname; } + try { + $themeconfig = theme_config::load($suitename); + } catch (Exception $e) { + // This theme has no theme config. + return []; + } + + // The theme will use all core contexts, except the one overridden by theme or its parent. + if (isset($themeconfig->parents)) { + foreach ($themeconfig->parents as $parent) { + $overrideclassname = "behat_theme_{$parent}_{$classname}"; + if (self::$environment->hasContextClass($overrideclassname)) { + return $overrideclassname; + } + } + } + if (self::$environment->hasContextClass($classname)) { return $classname; }