MDL-70897 various: uasort callback can not return bool
[moodle.git] / message / tests / externallib_test.php
index b25174b..087b276 100644 (file)
@@ -2091,7 +2091,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
         $this->assertCount(2, $contacts[0]['conversations']);
         // We can't rely on the ordering of conversations within the results, so sort by id first.
         usort($contacts[0]['conversations'], function($a, $b) {
-            return $a['id'] < $b['id'];
+            return $b['id'] <=> $a['id'];
         });
         $this->assertEquals(\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP, $contacts[0]['conversations'][0]['type']);
         $this->assertEquals(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL, $contacts[0]['conversations'][1]['type']);
@@ -2187,7 +2187,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
         $this->assertCount(2, $contacts[0]['conversations']);
         // We can't rely on the ordering of conversations within the results, so sort by id first.
         usort($contacts[0]['conversations'], function($a, $b) {
-            return $a['id'] < $b['id'];
+            return $b['id'] <=> $a['id'];
         });
         $this->assertEquals(\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP, $contacts[0]['conversations'][0]['type']);
         $this->assertEquals(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL, $contacts[0]['conversations'][1]['type']);
@@ -3538,7 +3538,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
      * @return bool
      */
     protected static function sort_contacts($a, $b) {
-        return $a['userid'] > $b['userid'];
+        return $a['userid'] <=> $b['userid'];
     }
 
     /**
@@ -3549,7 +3549,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
      * @return bool
      */
     protected static function sort_contacts_id($a, $b) {
-        return $a['id'] > $b['id'];
+        return $a['id'] <=> $b['id'];
     }
 
     /**
@@ -4422,7 +4422,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
         $conversations = $result['conversations'];
 
         usort($conversations, function($first, $second){
-            return $first['id'] > $second['id'];
+            return $first['id'] <=> $second['id'];
         });
 
         $selfconversation = array_shift($conversations);