diff --git a/course/classes/customfield/course_handler.php b/course/classes/customfield/course_handler.php index 5deeb4737ff..dede44dcbb9 100644 --- a/course/classes/customfield/course_handler.php +++ b/course/classes/customfield/course_handler.php @@ -71,7 +71,7 @@ class course_handler extends \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 434eb355bae..e76d410e05b 100644 --- a/customfield/tests/api_test.php +++ b/customfield/tests/api_test.php @@ -37,14 +37,6 @@ use \core_customfield\category_controller; */ 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 210a9669ba3..04ce151e65e 100644 --- a/customfield/tests/category_controller_test.php +++ b/customfield/tests/category_controller_test.php @@ -36,14 +36,6 @@ use \core_customfield\field_controller; */ 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 ab5b9da3806..d125c5c9c21 100644 --- a/customfield/tests/data_controller_test.php +++ b/customfield/tests/data_controller_test.php @@ -34,14 +34,6 @@ use core_customfield\data_controller; */ 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 ff26572fe05..a642919e262 100644 --- a/customfield/tests/field_controller_test.php +++ b/customfield/tests/field_controller_test.php @@ -38,14 +38,6 @@ use \core_customfield\field_controller; */ 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 38d8ebb9f84..c5335c37d9f 100644 --- a/customfield/tests/generator_test.php +++ b/customfield/tests/generator_test.php @@ -35,14 +35,6 @@ defined('MOODLE_INTERNAL') || die(); */ 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 bdb5d374b72..4a63085fb3f 100644 --- a/customfield/tests/privacy_test.php +++ b/customfield/tests/privacy_test.php @@ -38,14 +38,6 @@ use core_customfield\privacy\provider; */ 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 e69ae8cecdd..2605f6fde15 100644 --- a/lib/phpunit/classes/util.php +++ b/lib/phpunit/classes/util.php @@ -252,6 +252,9 @@ class phpunit_util extends testing_util { 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')) {