MDL-84448 lib: Fixed behat context check for grandchild themes

This commit is contained in:
Amanda Doughty
2025-02-20 12:00:33 +08:00
committed by Simey Lameze
parent 3c848c4dce
commit e5c6443bd8
@@ -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;
}