diff --git a/course/classes/customfield/course_handler.php b/course/classes/customfield/course_handler.php index 5deeb4737ff52..dede44dcbb960 100644 --- a/course/classes/customfield/course_handler.php +++ b/course/classes/customfield/course_handler.php @@ -71,7 +71,7 @@ public static function create(int $itemid = 0) : \core_customfield\handler { /** * Run reset code after unit tests to reset the singleton usage. */ - public static function reset_after_test(): void { + public static function reset_caches(): void { if (!PHPUNIT_TEST) { throw new \coding_exception('This feature is only intended for use in unit tests'); } diff --git a/customfield/tests/api_test.php b/customfield/tests/api_test.php index 434eb355baecc..e76d410e05b91 100644 --- a/customfield/tests/api_test.php +++ b/customfield/tests/api_test.php @@ -37,14 +37,6 @@ */ class core_customfield_api_testcase extends advanced_testcase { - /** - * Tear down to reset the singleton after each test. - */ - public function tearDown() { - core_course\customfield\course_handler::reset_after_test(); - parent::tearDown(); - } - /** * Get generator. * diff --git a/customfield/tests/category_controller_test.php b/customfield/tests/category_controller_test.php index 210a9669ba320..04ce151e65e68 100644 --- a/customfield/tests/category_controller_test.php +++ b/customfield/tests/category_controller_test.php @@ -36,14 +36,6 @@ */ class core_customfield_category_controller_testcase extends advanced_testcase { - /** - * Tear down to reset the singleton after each test. - */ - public function tearDown() { - core_course\customfield\course_handler::reset_after_test(); - parent::tearDown(); - } - /** * Get generator. * diff --git a/customfield/tests/data_controller_test.php b/customfield/tests/data_controller_test.php index ab5b9da380659..d125c5c9c2168 100644 --- a/customfield/tests/data_controller_test.php +++ b/customfield/tests/data_controller_test.php @@ -34,14 +34,6 @@ */ class core_customfield_data_controller_testcase extends advanced_testcase { - /** - * Tear down to reset the singleton after each test. - */ - public function tearDown() { - core_course\customfield\course_handler::reset_after_test(); - parent::tearDown(); - } - /** * Get generator. * diff --git a/customfield/tests/field_controller_test.php b/customfield/tests/field_controller_test.php index ff26572fe0595..a642919e2624a 100644 --- a/customfield/tests/field_controller_test.php +++ b/customfield/tests/field_controller_test.php @@ -38,14 +38,6 @@ */ class core_customfield_field_controller_testcase extends advanced_testcase { - /** - * Tear down to reset the singleton after each test. - */ - public function tearDown() { - core_course\customfield\course_handler::reset_after_test(); - parent::tearDown(); - } - /** * Get generator. * diff --git a/customfield/tests/generator_test.php b/customfield/tests/generator_test.php index 38d8ebb9f848a..c5335c37d9fef 100644 --- a/customfield/tests/generator_test.php +++ b/customfield/tests/generator_test.php @@ -35,14 +35,6 @@ */ class core_customfield_generator_testcase extends advanced_testcase { - /** - * Tear down to reset the singleton after each test. - */ - public function tearDown() { - core_course\customfield\course_handler::reset_after_test(); - parent::tearDown(); - } - /** * Get generator * @return core_customfield_generator diff --git a/customfield/tests/privacy_test.php b/customfield/tests/privacy_test.php index bdb5d374b729c..4a63085fb3f20 100644 --- a/customfield/tests/privacy_test.php +++ b/customfield/tests/privacy_test.php @@ -38,14 +38,6 @@ */ class core_customfield_privacy_testcase extends provider_testcase { - /** - * Tear down to reset the singleton after each test. - */ - public function tearDown() { - core_course\customfield\course_handler::reset_after_test(); - parent::tearDown(); - } - /** * Generate data. * diff --git a/lib/phpunit/classes/util.php b/lib/phpunit/classes/util.php index e69ae8cecddce..2605f6fde1574 100644 --- a/lib/phpunit/classes/util.php +++ b/lib/phpunit/classes/util.php @@ -252,6 +252,9 @@ public static function reset_all_data($detectchanges = false) { if (class_exists('\core\update\checker')) { \core\update\checker::reset_caches(true); } + if (class_exists('\core_course\customfield\course_handler')) { + \core_course\customfield\course_handler::reset_caches(); + } // Clear static cache within restore. if (class_exists('restore_section_structure_step')) {