initialise_cfg();
}
+ /**
+ * Restore theme CSS stored during behat setup.
+ */
+ public static function restore_saved_themes(): void {
+ global $CFG;
+
+ $themerev = theme_get_revision();
+
+ $framework = self::get_framework();
+ $storageroot = self::get_dataroot() . "/{$framework}/themedata";
+ $themenames = array_keys(\core_component::get_plugin_list('theme'));
+ $directions = ['ltr', 'rtl'];
+
+ $themeconfigs = array_map(function($themename) {
+ return \theme_config::load($themename);
+ }, $themenames);
+
+ foreach ($themeconfigs as $themeconfig) {
+ $themename = $themeconfig->name;
+ $themesubrev = theme_get_sub_revision_for_theme($themename);
+
+ $dirname = "{$storageroot}/{$themename}";
+ foreach ($directions as $direction) {
+ $cssfile = "{$dirname}/{$direction}.css";
+ if (file_exists($cssfile)) {
+ $themeconfig->set_css_content_cache(file_get_contents($cssfile));
+ }
+ }
+ }
+ }
+
/**
* Pause execution immediately.
*
behat_util::reset_all_data();
error_reporting($errorlevel);
+ if ($this->running_javascript()) {
+ // Fetch the user agent.
+ // This isused to choose between the SVG/Non-SVG versions of themes.
+ $useragent = $this->getSession()->evaluateScript('return navigator.userAgent;');
+ \core_useragent::instance(true, $useragent);
+
+ // Restore the saved themes.
+ behat_util::restore_saved_themes();
+ }
+
// Assign valid data to admin user (some generator-related code needs a valid user).
$user = $DB->get_record('user', array('username' => 'admin'));
\core\session\manager::set_user($user);