mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
Merge branch 'MDL-63834_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
657c74416d
@ -1982,6 +1982,15 @@ class api {
|
||||
|
||||
global $DB;
|
||||
|
||||
$validtypes = [
|
||||
self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
self::MESSAGE_CONVERSATION_TYPE_GROUP
|
||||
];
|
||||
|
||||
if (!in_array($type, $validtypes)) {
|
||||
throw new \moodle_exception('An invalid conversation type was specified.');
|
||||
}
|
||||
|
||||
// Sanity check.
|
||||
if ($type == self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
|
||||
if (count($userids) > 2) {
|
||||
|
@ -4793,6 +4793,14 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||
$this->assertEquals($conversation->id, $member3->conversationid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating an invalid conversation.
|
||||
*/
|
||||
public function test_create_conversation_invalid() {
|
||||
$this->expectException('moodle_exception');
|
||||
\core_message\api::create_conversation(3, [1, 2, 3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating an individual conversation with too many members.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user