From 6c7a99e0596d4d2db2ddcc8aee782c7a9f5ee4fa Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 3 Jul 2025 15:51:29 +0100 Subject: [PATCH] MDL-84695 mod_qbank: Fix unit tests for MS SQL server --- .../tests/local/bank/question_bank_helper_test.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/question/tests/local/bank/question_bank_helper_test.php b/question/tests/local/bank/question_bank_helper_test.php index 283002ec004..92069e47c16 100644 --- a/question/tests/local/bank/question_bank_helper_test.php +++ b/question/tests/local/bank/question_bank_helper_test.php @@ -407,10 +407,6 @@ final class question_bank_helper_test extends \advanced_testcase { self::setAdminUser(); $course = self::getDataGenerator()->create_course(); - // Create module other than a qbank. - $wiki = self::getDataGenerator()->create_module('wiki', [ - 'course' => $course->id, - ]); $modinfo = get_fast_modinfo($course); $qbanks = $modinfo->get_instances_of('qbank'); $this->assertCount(0, $qbanks); @@ -420,6 +416,12 @@ final class question_bank_helper_test extends \advanced_testcase { $this->assertEquals(get_string('systembank', 'question'), $qbank->get_name()); $modrecord = $DB->get_record('qbank', ['id' => $qbank->instance]); $this->assertEquals(question_bank_helper::TYPE_SYSTEM, $modrecord->type); + // Create module other than a qbank with an ID that isn't used by a qbank yet. + do { + $wiki = self::getDataGenerator()->create_module('wiki', [ + 'course' => $course->id, + ]); + } while ($DB->record_exists('qbank', ['id' => $wiki->id])); // Swap the qbank instance record for one with the same ID as the wiki instance. $newqbank = clone($modrecord); $newqbank->id = $wiki->id;