mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-48302 behat: Reset cache before scenario
This commit is contained in:
parent
ca0e301c7b
commit
ef1d45b394
@ -290,4 +290,31 @@ class behat_util extends testing_util {
|
||||
return behat_command::get_behat_dir() . '/test_environment_enabled.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset contents of all database tables to initial values, reset caches, etc.
|
||||
*/
|
||||
public static function reset_all_data() {
|
||||
// Reset all static caches.
|
||||
accesslib_clear_all_caches(true);
|
||||
// Reset the nasty strings list used during the last test.
|
||||
nasty_strings::reset_used_strings();
|
||||
|
||||
filter_manager::reset_caches();
|
||||
|
||||
// Reset course and module caches.
|
||||
if (class_exists('format_base')) {
|
||||
// If file containing class is not loaded, there is no cache there anyway.
|
||||
format_base::reset_course_cache(0);
|
||||
}
|
||||
get_fast_modinfo(0, 0, true);
|
||||
|
||||
// Inform data generator.
|
||||
self::get_data_generator()->reset();
|
||||
|
||||
// Purge dataroot directory.
|
||||
self::reset_dataroot();
|
||||
|
||||
// Reset database.
|
||||
self::reset_database();
|
||||
}
|
||||
}
|
||||
|
@ -192,13 +192,7 @@ class behat_hooks extends behat_base {
|
||||
// Reset $SESSION.
|
||||
\core\session\manager::init_empty_session();
|
||||
|
||||
behat_util::reset_database();
|
||||
behat_util::reset_dataroot();
|
||||
|
||||
accesslib_clear_all_caches(true);
|
||||
|
||||
// Reset the nasty strings list used during the last test.
|
||||
nasty_strings::reset_used_strings();
|
||||
behat_util::reset_all_data();
|
||||
|
||||
// Assign valid data to admin user (some generator-related code needs a valid user).
|
||||
$user = $DB->get_record('user', array('username' => 'admin'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user