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();
+ }
}
// 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'));