mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-66836-master' of https://github.com/sammarshallou/moodle
This commit is contained in:
commit
ef2f26b8b1
@ -345,6 +345,23 @@ class behat_util extends testing_util {
|
||||
return behat_command::get_parent_behat_dir() . '/test_environment_enabled.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes config settings that were added to the main $CFG config within the Behat CLI
|
||||
* run.
|
||||
*
|
||||
* Database storage is already handled by reset_database and existing config values will
|
||||
* be reset automatically by initialise_cfg(), so we only need to remove added ones.
|
||||
*/
|
||||
public static function remove_added_config() {
|
||||
global $CFG;
|
||||
if (!empty($CFG->behat_cli_added_config)) {
|
||||
foreach ($CFG->behat_cli_added_config as $key => $value) {
|
||||
unset($CFG->{$key});
|
||||
}
|
||||
unset($CFG->behat_cli_added_config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset contents of all database tables to initial values, reset caches, etc.
|
||||
*/
|
||||
@ -375,6 +392,7 @@ class behat_util extends testing_util {
|
||||
|
||||
// Initialise $CFG with default values. This is needed for behat cli process, so we don't have modified
|
||||
// $CFG values from the old run. @see set_config.
|
||||
self::remove_added_config();
|
||||
initialise_cfg();
|
||||
}
|
||||
|
||||
|
@ -1405,6 +1405,14 @@ function set_config($name, $value, $plugin=null) {
|
||||
$config->value = $value;
|
||||
$DB->insert_record('config', $config, false);
|
||||
}
|
||||
// When setting config during a Behat test (in the CLI script, not in the web browser
|
||||
// requests), remember which ones are set so that we can clear them later.
|
||||
if (defined('BEHAT_TEST')) {
|
||||
if (!property_exists($CFG, 'behat_cli_added_config')) {
|
||||
$CFG->behat_cli_added_config = [];
|
||||
}
|
||||
$CFG->behat_cli_added_config[$name] = true;
|
||||
}
|
||||
}
|
||||
if ($name === 'siteidentifier') {
|
||||
cache_helper::update_site_identifier($value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user