Merge branch 'MDL-75559-39' of https://github.com/andrewnicols/moodle into MOODLE_39_STABLE

This commit is contained in:
Jun Pataleta
2022-09-29 10:53:14 +08:00
+30 -1
View File
@@ -333,6 +333,34 @@ class behat_config_util {
return $this->get_component_contexts($component);
}
/**
* Sort the list of components contexts.
*
* This ensures that contexts are sorted consistently.
* Core hooks defined in the behat_hooks class _must_ be defined first.
*
* @param array $contexts
* @return array The sorted context list
*/
protected function sort_component_contexts(array $contexts): array {
// Ensure that the lib_tests are first as they include the root of all tests, hooks, and more.
uksort($contexts, function($a, $b): int {
if ($a === 'behat_hooks') {
return -1;
}
if ($b === 'behat_hooks') {
return 1;
}
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
});
return $contexts;
}
/**
* Behat config file specifing the main context class,
* the required Behat extensions and Moodle test wwwroot.
@@ -1537,8 +1565,9 @@ class behat_config_util {
}
// Sort the list of contexts.
ksort($contexts);
$contexts = $this->sort_component_contexts($contexts);
// Cache it for subsequent fetches.
$this->themecontexts[$theme] = $contexts;
return $contexts;