From fb8840d29159ff012fea880717ddeb0cf429b510 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Fri, 2 May 2014 11:38:17 +0200 Subject: [PATCH] MDL-30106 forum: get_posts WS fixes in data generator and def. values --- mod/forum/externallib.php | 5 +++-- mod/forum/tests/externallib_test.php | 2 +- mod/forum/tests/generator/lib.php | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mod/forum/externallib.php b/mod/forum/externallib.php index 139358e8610..98b144cd4f9 100644 --- a/mod/forum/externallib.php +++ b/mod/forum/externallib.php @@ -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(); diff --git a/mod/forum/tests/externallib_test.php b/mod/forum/tests/externallib_test.php index 9f85647600d..21c46290817 100644 --- a/mod/forum/tests/externallib_test.php +++ b/mod/forum/tests/externallib_test.php @@ -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) diff --git a/mod/forum/tests/generator/lib.php b/mod/forum/tests/generator/lib.php index a371c15ec6d..8d91e307849 100644 --- a/mod/forum/tests/generator/lib.php +++ b/mod/forum/tests/generator/lib.php @@ -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'])) {