MDL-30106 forum: get_posts WS fixes in data generator and def. values
authorJuan Leyva <juanleyvadelgado@gmail.com>
Fri, 2 May 2014 09:38:17 +0000 (11:38 +0200)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Mon, 5 May 2014 09:56:43 +0000 (11:56 +0200)
mod/forum/externallib.php
mod/forum/tests/externallib_test.php
mod/forum/tests/generator/lib.php

index 139358e..98b144c 100644 (file)
@@ -382,7 +382,7 @@ class mod_forum_external extends external_api {
      * @return array the forum post details
      * @since Moodle 2.7
      */
-    public static function get_forum_discussion_posts($discussionid, $sortby = "id", $sortdirection = "ASC") {
+    public static function get_forum_discussion_posts($discussionid, $sortby = "created", $sortdirection = "DESC") {
         global $CFG, $DB, $USER;
 
         $warnings = array();
@@ -463,9 +463,10 @@ class mod_forum_external extends external_api {
                 $posts[$pid]->postread = false;
             }
             $posts[$pid]->canreply = $canreply;
-            $posts[$pid]->children = array();
             if (!empty($posts[$pid]->children)) {
                 $posts[$pid]->children = array_keys($posts[$pid]->children);
+            } else {
+                $posts[$pid]->children = array();
             }
 
             $user = new stdclass();
index 9f85647..21c4629 100644 (file)
@@ -491,7 +491,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
             'attachment' => $discussion1reply1->attachment,
             'totalscore' => $discussion1reply1->totalscore,
             'mailnow' => $discussion1reply1->mailnow,
-            'children' => array(),
+            'children' => array(4),
             'canreply' => true,
             'postread' => false,
             'userfullname' => fullname($user2)
index a371c15..8d91e30 100644 (file)
@@ -199,15 +199,15 @@ class mod_forum_generator extends testing_module_generator {
         }
 
         if (!isset($record['mailed'])) {
-            $record['mailed'] = 1;
+            $record['mailed'] = 0;
         }
 
         if (!isset($record['messageformat'])) {
-            $record['messageformat'] = 1;
+            $record['messageformat'] = 0;
         }
 
         if (!isset($record['messagetrust'])) {
-            $record['messagetrust'] = 1;
+            $record['messagetrust'] = 0;
         }
 
         if (!isset($record['attachment'])) {