Skip to content

Commit

Permalink
MDL-49203 webservices: Fix unit tests for avoid random order issues
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jleyva committed Apr 2, 2015
1 parent 2016c7d commit e7f4cf2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions comment/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function test_get_comments() {
$cmtid1 = $DB->insert_record('comments', $newcmt);

$newcmt->content = 'New comment 2';
$newcmt->timecreated = time() + 1;
$cmtid2 = $DB->insert_record('comments', $newcmt);

$contextlevel = 'module';
Expand All @@ -126,7 +127,7 @@ public function test_get_comments() {
$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']);
}
}

0 comments on commit e7f4cf2

Please sign in to comment.