MDL-68388 core_grades: Tweak unit test assertion to make Oracle happy
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 26 May 2020 17:00:24 +0000 (19:00 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 26 May 2020 17:00:24 +0000 (19:00 +0200)
Also modify some comments and get rid of some void return types.

grade/edit/letter/index.php
lib/tests/gradelib_test.php

index f7aa942..b72e203 100644 (file)
@@ -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);
         }
index 97d500f..37cd372 100644 (file)
@@ -88,7 +88,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);
 
@@ -250,7 +250,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();
 
         // Setup some basics.
@@ -274,7 +275,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();