From 70b773082759e3c538e6224c3e01a21a80a83511 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 20 Feb 2024 10:54:12 +0800 Subject: [PATCH] MDL-80862 testing: Reset task manager between behat tests --- lib/behat/classes/util.php | 3 +++ lib/classes/task/manager.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/behat/classes/util.php b/lib/behat/classes/util.php index 3f4f28f2894e0..3481ff2f43290 100644 --- a/lib/behat/classes/util.php +++ b/lib/behat/classes/util.php @@ -432,6 +432,9 @@ public static function reset_all_data() { // Inform data generator. self::get_data_generator()->reset(); + // Reset the task manager. + \core\task\manager::reset_state(); + // 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(); diff --git a/lib/classes/task/manager.php b/lib/classes/task/manager.php index 90f7c90a03531..808ee6ce8e519 100644 --- a/lib/classes/task/manager.php +++ b/lib/classes/task/manager.php @@ -64,6 +64,15 @@ class manager { */ public static $mode; + /** + * Reset the state of the task manager. + */ + public static function reset_state(): void { + self::$miniqueue = null; + self::$numtasks = null; + self::$mode = null; + } + /** * Given a component name, will load the list of tasks in the db/tasks.php file for that component. *