Merge branch 'MDL-63692-master-fix' of git://github.com/junpataleta/moodle

This commit is contained in:
Jun Pataleta 2018-11-20 14:48:08 +08:00
commit bc7195fa02
2 changed files with 24 additions and 26 deletions

View File

@ -963,7 +963,7 @@ class api {
global $DB;
// Get the context for this conversation.
$conversation = $DB->get_records('message_conversations', ['id' => $conversationid]);
$conversation = $DB->get_record('message_conversations', ['id' => $conversationid]);
$userctx = \context_user::instance($userid);
if (empty($conversation->contextid)) {
// When the conversation hasn't any contextid value defined, the favourite will be added to the user context.

View File

@ -1517,9 +1517,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// Test for users with any group conversation in course1.
provider::add_conversations_in_context($userlist1, $component, $itemtype);
$this->assertCount(3, $userlist1);
$this->assertEquals(
[$user1->id, $user2->id, $user3->id],
$userlist1->get_userids());
$this->assertEquals([$user1->id, $user2->id, $user3->id], $userlist1->get_userids(), '', 0, 10, true);
// Test for users with any group conversation in course2.
$userlist2 = new \core_privacy\local\request\userlist($coursecontext2, 'core_message');
@ -1845,8 +1843,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be 9 conversation members - (2 + 2) individual + (3 + 2) group.
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
// There should be 5 notifications - 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 3 favourite conversations.
$this->assertEquals(3, $DB->count_records('favourite'));
@ -1863,8 +1861,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be still 2 blocked users.
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
// There should be still 5 notifications - 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 5 messages - 3 individual - 2 group (course2).
$this->assertEquals(5, $DB->count_records('messages'));
@ -2018,8 +2016,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be 9 conversation members - (2 + 2) individual + (3 + 2) group.
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
// There should be 5 notifications - 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 3 favourite conversations.
$this->assertEquals(3, $DB->count_records('favourite'));
@ -2035,7 +2033,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertEquals(4, $DB->count_records('message_user_actions'));
$this->assertEquals(4, $DB->count_records('message_conversations'));
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
$this->assertEquals(5, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('favourite'));
// Delete individual conversations for all users in system context.
@ -2049,7 +2047,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertEquals(4, $DB->count_records('message_user_actions'));
$this->assertEquals(4, $DB->count_records('message_conversations'));
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
$this->assertEquals(5, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('favourite'));
}
@ -2177,8 +2175,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be 9 conversation members - (2 + 2) individual + (3 + 2) group.
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
// There should be 5 notifications - 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 3 favourite conversations.
$this->assertEquals(3, $DB->count_records('favourite'));
@ -2194,7 +2192,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertEquals(4, $DB->count_records('message_user_actions'));
$this->assertEquals(4, $DB->count_records('message_conversations'));
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
$this->assertEquals(5, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('favourite'));
// Delete individual conversations for all users in user context.
@ -2208,7 +2206,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertEquals(4, $DB->count_records('message_user_actions'));
$this->assertEquals(4, $DB->count_records('message_conversations'));
$this->assertEquals(9, $DB->count_records('message_conversation_members'));
$this->assertEquals(5, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('favourite'));
}
@ -2312,8 +2310,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be 2 blocked users.
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
// There should be 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 6 messages.
$this->assertEquals(6, $DB->count_records('messages'));
@ -2349,8 +2347,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be still 2 blocked users.
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
// There should be still 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 4 messages - 3 private + 1 group sent by user2.
$this->assertEquals(4, $DB->count_records('messages'));
@ -2495,8 +2493,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be 2 blocked users.
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
// There should be 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 6 messages.
$this->assertEquals(6, $DB->count_records('messages'));
@ -2528,7 +2526,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertEquals(2, $DB->count_records('message_contacts'));
$this->assertEquals(2, $DB->count_records('message_contact_requests'));
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
$this->assertEquals(5, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('notifications'));
$this->assertEquals(6, $DB->count_records('messages'));
$this->assertEquals(4, $DB->count_records('message_user_actions'));
$this->assertEquals(4, $DB->count_records('message_conversations'));
@ -2544,7 +2542,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertEquals(2, $DB->count_records('message_contacts'));
$this->assertEquals(2, $DB->count_records('message_contact_requests'));
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
$this->assertEquals(5, $DB->count_records('notifications'));
$this->assertEquals(3, $DB->count_records('notifications'));
$this->assertEquals(6, $DB->count_records('messages'));
$this->assertEquals(4, $DB->count_records('message_user_actions'));
$this->assertEquals(4, $DB->count_records('message_conversations'));
@ -2566,8 +2564,8 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
// There should be still 2 blocked users.
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
// There should be still 3 notifications + 2 for the contact request.
$this->assertEquals(5, $DB->count_records('notifications'));
// There should be 3 notifications.
$this->assertEquals(3, $DB->count_records('notifications'));
// There should be 4 messages - 3 private + 1 group sent by user3.
$this->assertEquals(4, $DB->count_records('messages'));