MDL-50995 mod_forum: Fix WS to not rely in the DB ordering defaults
authorJuan Leyva <juanleyvadelgado@gmail.com>
Wed, 9 Sep 2015 10:15:17 +0000 (12:15 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 9 Sep 2015 10:59:53 +0000 (12:59 +0200)
mod/forum/tests/externallib_test.php

index 7f095b4..26ef466 100644 (file)
@@ -812,9 +812,16 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
         $posts = external_api::clean_returnvalue(mod_forum_external::get_forum_discussion_posts_returns(), $posts);
         // We receive the discussion and the post.
         $this->assertEquals(2, count($posts['posts']));
-        $this->assertEquals($post['postid'], $posts['posts'][1]['id']);
-        $this->assertEquals('some subject', $posts['posts'][1]['subject']);
-        $this->assertEquals('some text here...', $posts['posts'][1]['message']);
+
+        $tested = false;
+        foreach ($posts['posts'] as $postel) {
+            if ($post['postid'] == $postel['id']) {
+                $this->assertEquals('some subject', $postel['subject']);
+                $this->assertEquals('some text here...', $postel['message']);
+                $tested = true;
+            }
+        }
+        $this->assertTrue($tested);
 
         // Check not posting in groups the user is not member of.
         $group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));