From 640838c11789d470550b0d07a2093424c57d42ed Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 26 May 2020 19:00:24 +0200 Subject: [PATCH] MDL-68388 core_grades: Tweak unit test assertion to make Oracle happy Also modify some comments and get rid of some void return types. --- grade/edit/letter/index.php | 5 ++++- lib/tests/gradelib_test.php | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/grade/edit/letter/index.php b/grade/edit/letter/index.php index f7aa9429ef4..b72e2035fab 100644 --- a/grade/edit/letter/index.php +++ b/grade/edit/letter/index.php @@ -229,8 +229,11 @@ if (!$edit) { } } + // Cache the changed letters. if (!empty($letters)) { - // Ensure that the letters are correctly sorted. + + // For some reason, the cache saves it in the order in which they were entered + // but we really want to order them in descending order so we sort it here. krsort($letters); $cache->set($context->id, $letters); } diff --git a/lib/tests/gradelib_test.php b/lib/tests/gradelib_test.php index 1bf6f5ecf8f..1da820dcff8 100644 --- a/lib/tests/gradelib_test.php +++ b/lib/tests/gradelib_test.php @@ -87,7 +87,7 @@ class core_gradelib_testcase extends advanced_testcase { $letters = $cache->get($context->id); $this->assertEquals(1, count($letters)); - $this->assertEquals($letter->letter, $letters['100.00000']); + $this->assertTrue(in_array($letter->letter, $letters)); remove_grade_letters($context, false); @@ -249,7 +249,8 @@ class core_gradelib_testcase extends advanced_testcase { /** * Test the caching of grade letters. */ - public function test_get_grade_letters(): void { + public function test_get_grade_letters() { + $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -272,7 +273,7 @@ class core_gradelib_testcase extends advanced_testcase { /** * Test custom letters. */ - public function test_get_grade_letters_custom(): void { + public function test_get_grade_letters_custom() { global $DB; $this->resetAfterTest();