Skip to content

Commit

Permalink
MDL-60018 mod_chat: Fix chatmethod field type in get_chats_by_courses WS
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Sep 6, 2017
1 parent 3393db1 commit 51cd0c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mod/chat/classes/external.php
Expand Up @@ -594,7 +594,8 @@ public static function get_chats_by_courses_returns() {
'intro' => new external_value(PARAM_RAW, 'The Chat intro'),
'introformat' => new external_format_value('intro'),
'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL),
'chatmethod' => new external_value(PARAM_ALPHA, 'chat method (sockets, daemon)', VALUE_OPTIONAL),
'chatmethod' => new external_value(PARAM_PLUGIN, 'chat method (sockets, ajax, header_js)',
VALUE_OPTIONAL),
'keepdays' => new external_value(PARAM_INT, 'keep days', VALUE_OPTIONAL),
'studentlogs' => new external_value(PARAM_INT, 'student logs visible to everyone', VALUE_OPTIONAL),
'chattime' => new external_value(PARAM_INT, 'chat time', VALUE_OPTIONAL),
Expand Down
7 changes: 6 additions & 1 deletion mod/chat/tests/externallib_test.php
Expand Up @@ -223,9 +223,13 @@ public function test_view_chat() {
* Test get_chats_by_courses
*/
public function test_get_chats_by_courses() {
global $DB, $USER;
global $DB, $USER, $CFG;
$this->resetAfterTest(true);
$this->setAdminUser();

// Set global chat method.
$CFG->chat_method = 'header_js';

$course1 = self::getDataGenerator()->create_course();
$chatoptions1 = array(
'course' => $course1->id,
Expand Down Expand Up @@ -272,6 +276,7 @@ public function test_get_chats_by_courses() {

$this->assertCount(1, $chats['chats']);
$this->assertEquals('Second Chat', $chats['chats'][0]['name']);
$this->assertEquals('header_js', $chats['chats'][0]['chatmethod']);
// We see 17 fields.
$this->assertCount(17, $chats['chats'][0]);
// As an Admin you can see some chat properties like 'section'.
Expand Down

0 comments on commit 51cd0c4

Please sign in to comment.