From 007449c03f2d2e0c949fe971ee98dea95ea76be4 Mon Sep 17 00:00:00 2001 From: Tasio Date: Fri, 13 Jun 2025 10:26:25 +0200 Subject: [PATCH] MDL-78233 accesslib: remove unreliable test Co-authored-by: Marina Glancy --- lib/tests/accesslib_test.php | 64 ------------------------------------ 1 file changed, 64 deletions(-) diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index e8b266eefba..5bd3c9ccc62 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -4317,70 +4317,6 @@ final class accesslib_test extends advanced_testcase { $this->assertEquals($perms1, $perms2); } - /** - * Checks install performance in update_capabilities. - * - * @covers ::update_capabilities() - */ - public function test_update_capabilities_install_performance(): void { - global $DB; - - $this->resetAfterTest(); - - // Get rid of all the capabilities for forum. - $testmodule = 'forum'; - $DB->delete_records_select('capabilities', 'name LIKE ?', ['mod/' . $testmodule . ':%']); - - $beforeq = $DB->perf_get_queries(); - update_capabilities('mod_' . $testmodule); - $afterq = $DB->perf_get_queries(); - - // In my testing there are currently 237 queries; there were 373 before a performance - // fix. This test confirms performance doesn't degrade to near the previous level. - $this->assertLessThan(300, $afterq - $beforeq); - } - - /** - * Checks install performance in update_capabilities when a new capability is cloned. - * - * This only has impact if there are a significant number of overrides of the existing - * capability. - * - * @covers ::update_capabilities() - */ - public function test_update_capabilities_clone_performance(): void { - global $DB; - - $this->resetAfterTest(); - - // Create a bunch of activities in a course. In each one, override so manager doesn't have - // moodle/course:manageactivities. - $generator = $this->getDataGenerator(); - $course = $generator->create_course(); - $roleid = $DB->get_field('role', 'id', ['shortname' => 'manager']); - for ($i = 0; $i < 100; $i++) { - $page = $generator->create_module('page', ['course' => $course->id]); - $contextid = context_module::instance($page->cmid)->id; - assign_capability('moodle/course:manageactivities', CAP_PREVENT, $roleid, $contextid); - } - - // Get rid of one of the capabilities for forum, which clones moodle/course:manageactivities. - $DB->delete_records('capabilities', ['name' => 'mod/forum:addinstance']); - - // Clear the context cache to simulate a realistic situation where we don't already have - // all those contexts in the cache. - accesslib_clear_all_caches_for_unit_testing(); - - $beforeq = $DB->perf_get_queries(); - update_capabilities('mod_forum'); - $afterq = $DB->perf_get_queries(); - - // In my testing there are currently 214 queries after performance was improved for cloning, - // compared to 414 before. This test confirms performance doesn't degrade to near the - // previous level. - $this->assertLessThan(300, $afterq - $beforeq); - } - /** * Tests update_capabilities when a capability is cloned, but there are existing settings * for that capability.