MDL-49203 webservices: Fix unit tests for avoid random order issues
authorJuan Leyva <juanleyvadelgado@gmail.com>
Thu, 2 Apr 2015 10:56:42 +0000 (12:56 +0200)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Thu, 2 Apr 2015 10:57:22 +0000 (12:57 +0200)
This problem usually happens in Postgres where a set of records is
ordered by a timestamp column and there are two or more records with
the same value

comment/tests/externallib_test.php

index d977eb5..c6a7433 100644 (file)
@@ -106,6 +106,7 @@ class core_comment_externallib_testcase extends externallib_advanced_testcase {
         $cmtid1 = $DB->insert_record('comments', $newcmt);
 
         $newcmt->content  = 'New comment 2';
+        $newcmt->timecreated  = time() + 1;
         $cmtid2 = $DB->insert_record('comments', $newcmt);
 
         $contextlevel = 'module';
@@ -126,7 +127,7 @@ class core_comment_externallib_testcase extends externallib_advanced_testcase {
         $this->assertEquals($user->id, $result['comments'][0]['userid']);
         $this->assertEquals($user->id, $result['comments'][1]['userid']);
 
-        $this->assertEquals($cmtid1, $result['comments'][0]['id']);
-        $this->assertEquals($cmtid2, $result['comments'][1]['id']);
+        $this->assertEquals($cmtid2, $result['comments'][0]['id']);
+        $this->assertEquals($cmtid1, $result['comments'][1]['id']);
     }
 }