MDL-66568 behat: Support building of themes for behat

This commit is contained in:
Andrew Nicols
2020-06-17 07:51:47 +08:00
parent d57acc9d80
commit bcbc91091c
2 changed files with 36 additions and 0 deletions
+6
View File
@@ -164,6 +164,8 @@ if ($options['install']) {
mtrace("Acceptance tests site installed");
}
// Note: Do not build the themes here. This is done during the 'enable' stage.
} else if ($options['drop']) {
// Ensure no tests are running.
test_lock::acquire('behat');
@@ -182,6 +184,10 @@ if ($options['install']) {
// Enable test mode.
behat_util::start_test_mode($options['add-core-features-to-theme'], $options['optimize-runs'], $parallel, $run);
// Themes are only built in the 'enable' command.
behat_util::build_themes();
mtrace("Testing environment themes built");
// This is only displayed once for parallel install.
if (empty($run)) {
// Notify user that 2.5 profile has been converted to 3.5.
+30
View File
@@ -32,6 +32,7 @@ require_once(__DIR__ . '/behat_config_manager.php');
require_once(__DIR__ . '/../../filelib.php');
require_once(__DIR__ . '/../../clilib.php');
require_once(__DIR__ . '/../../csslib.php');
use Behat\Mink\Session;
use Behat\Mink\Exception\ExpectationException;
@@ -131,6 +132,35 @@ class behat_util extends testing_util {
self::store_database_state();
}
/**
* Build theme CSS.
*/
public static function build_themes() {
global $CFG;
require_once("{$CFG->libdir}/outputlib.php");
$themenames = array_keys(\core_component::get_plugin_list('theme'));
// Load the theme configs.
$themeconfigs = array_map(function($themename) {
return \theme_config::load($themename);
}, $themenames);
// Build the list of themes and cache them in local cache.
$themes = theme_build_css_for_themes($themeconfigs, ['ltr'], true);
$framework = self::get_framework();
$storageroot = self::get_dataroot() . "/{$framework}/themedata";
foreach ($themes as $themename => $themedata) {
$dirname = "{$storageroot}/{$themename}";
check_dir_exists($dirname);
foreach ($themedata as $direction => $css) {
file_put_contents("{$dirname}/{$direction}.css", $css);
}
}
}
/**
* Drops dataroot and remove test database tables
* @throws coding_exception