mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
Merge branch 'MDL-64773_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
a6646dfd92
39 changed files with 1093 additions and 21 deletions
|
@ -1302,6 +1302,50 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
|||
$this->assertEquals($expectedmessagetext, $messages[0]->text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test verifying get_conversations identifies if a conversation is muted or not.
|
||||
*/
|
||||
public function test_get_conversations_some_muted() {
|
||||
// Create some users.
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
$user3 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation1 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
testhelper::send_fake_message_to_conversation($user1, $conversation1->id, 'Message 1');
|
||||
testhelper::send_fake_message_to_conversation($user2, $conversation1->id, 'Message 2');
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
|
||||
$conversation2 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user3->id]);
|
||||
testhelper::send_fake_message_to_conversation($user1, $conversation2->id, 'Message 1');
|
||||
testhelper::send_fake_message_to_conversation($user2, $conversation2->id, 'Message 2');
|
||||
|
||||
$conversation3 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP,
|
||||
[$user1->id, $user2->id]);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation3->id);
|
||||
|
||||
$conversation4 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP,
|
||||
[$user1->id, $user3->id]);
|
||||
|
||||
$conversations = \core_message\api::get_conversations($user1->id);
|
||||
|
||||
usort($conversations, function($first, $second){
|
||||
return $first->id > $second->id;
|
||||
});
|
||||
|
||||
$conv1 = array_shift($conversations);
|
||||
$conv2 = array_shift($conversations);
|
||||
$conv3 = array_shift($conversations);
|
||||
$conv4 = array_shift($conversations);
|
||||
|
||||
$this->assertTrue($conv1->ismuted);
|
||||
$this->assertFalse($conv2->ismuted);
|
||||
$this->assertTrue($conv3->ismuted);
|
||||
$this->assertFalse($conv4->ismuted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests retrieving conversations with a limit and offset to ensure pagination works correctly.
|
||||
*/
|
||||
|
@ -4912,6 +4956,84 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
|||
$this->assertEquals(0, $DB->count_records('message_users_blocked'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test muting a conversation.
|
||||
*/
|
||||
public function test_mute_conversation() {
|
||||
global $DB;
|
||||
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[
|
||||
$user1->id,
|
||||
$user2->id
|
||||
]
|
||||
);
|
||||
$conversationid = $conversation->id;
|
||||
|
||||
\core_message\api::mute_conversation($user1->id, $conversationid);
|
||||
|
||||
$mutedconversation = $DB->get_records('message_conversation_actions');
|
||||
|
||||
$this->assertCount(1, $mutedconversation);
|
||||
|
||||
$mutedconversation = reset($mutedconversation);
|
||||
|
||||
$this->assertEquals($user1->id, $mutedconversation->userid);
|
||||
$this->assertEquals($conversationid, $mutedconversation->conversationid);
|
||||
$this->assertEquals(\core_message\api::CONVERSATION_ACTION_MUTED, $mutedconversation->action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unmuting a conversation.
|
||||
*/
|
||||
public function test_unmute_conversation() {
|
||||
global $DB;
|
||||
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[
|
||||
$user1->id,
|
||||
$user2->id
|
||||
]
|
||||
);
|
||||
$conversationid = $conversation->id;
|
||||
|
||||
\core_message\api::mute_conversation($user1->id, $conversationid);
|
||||
\core_message\api::unmute_conversation($user1->id, $conversationid);
|
||||
|
||||
$this->assertEquals(0, $DB->count_records('message_conversation_actions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a conversation is muted.
|
||||
*/
|
||||
public function test_is_conversation_muted() {
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(
|
||||
\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[
|
||||
$user1->id,
|
||||
$user2->id
|
||||
]
|
||||
);
|
||||
$conversationid = $conversation->id;
|
||||
|
||||
$this->assertFalse(\core_message\api::is_conversation_muted($user1->id, $conversationid));
|
||||
|
||||
\core_message\api::mute_conversation($user1->id, $conversationid);
|
||||
|
||||
$this->assertTrue(\core_message\api::is_conversation_muted($user1->id, $conversationid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test is contact check.
|
||||
*/
|
||||
|
@ -5772,6 +5894,32 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
|||
\core_message\api::send_message_to_conversation($user2->id, $ic1->id, 'test', FORMAT_MOODLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the get_conversation() function with a muted conversation.
|
||||
*/
|
||||
public function test_get_conversation_with_muted_conversation() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$this->setUser($user1);
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$conversation = \core_message\api::get_conversation($user1->id, $conversation->id);
|
||||
|
||||
$this->assertFalse($conversation->ismuted);
|
||||
|
||||
// Now, mute the conversation.
|
||||
\core_message\api::mute_conversation($user1->id, $conversation->id);
|
||||
|
||||
$conversation = \core_message\api::get_conversation($user1->id, $conversation->id);
|
||||
|
||||
$this->assertTrue($conversation->ismuted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_get_conversation_counts().
|
||||
*/
|
||||
|
|
|
@ -1022,6 +1022,168 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
|
|||
core_message_external::decline_contact_request($user1->id, $user2->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test muting conversations.
|
||||
*/
|
||||
public function test_mute_conversations() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$this->setUser($user1);
|
||||
|
||||
// Muting a conversation.
|
||||
$return = core_message_external::mute_conversations($user1->id, [$conversation->id]);
|
||||
$return = external_api::clean_returnvalue(core_message_external::mute_conversations_returns(), $return);
|
||||
$this->assertEquals(array(), $return);
|
||||
|
||||
// Get list of muted conversations.
|
||||
$mca = $DB->get_record('message_conversation_actions', []);
|
||||
|
||||
$this->assertEquals($user1->id, $mca->userid);
|
||||
$this->assertEquals($conversation->id, $mca->conversationid);
|
||||
$this->assertEquals(\core_message\api::CONVERSATION_ACTION_MUTED, $mca->action);
|
||||
|
||||
// Muting a conversation that is already muted.
|
||||
$return = core_message_external::mute_conversations($user1->id, [$conversation->id]);
|
||||
$return = external_api::clean_returnvalue(core_message_external::mute_conversations_returns(), $return);
|
||||
$this->assertEquals(array(), $return);
|
||||
|
||||
$this->assertEquals(1, $DB->count_records('message_conversation_actions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test muting a conversation with messaging disabled.
|
||||
*/
|
||||
public function test_mute_conversations_messaging_disabled() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create some skeleton data just so we can call the WS.
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$this->setUser($user1);
|
||||
|
||||
// Disable messaging.
|
||||
$CFG->messaging = 0;
|
||||
|
||||
// Ensure an exception is thrown.
|
||||
$this->expectException('moodle_exception');
|
||||
core_message_external::mute_conversations($user1->id, [$conversation->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test muting a conversation with no permission.
|
||||
*/
|
||||
public function test_mute_conversations_no_permission() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create some skeleton data just so we can call the WS.
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
$user3 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$this->setUser($user3);
|
||||
|
||||
// Ensure an exception is thrown.
|
||||
$this->expectException('required_capability_exception');
|
||||
core_message_external::mute_conversations($user1->id, [$conversation->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unmuting conversations.
|
||||
*/
|
||||
public function test_unmute_conversations() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$this->setUser($user1);
|
||||
|
||||
// Mute the conversation.
|
||||
\core_message\api::mute_conversation($user1->id, $conversation->id);
|
||||
|
||||
// Unmuting a conversation.
|
||||
$return = core_message_external::unmute_conversations($user1->id, [$conversation->id]);
|
||||
$return = external_api::clean_returnvalue(core_message_external::unmute_conversations_returns(), $return);
|
||||
$this->assertEquals(array(), $return);
|
||||
|
||||
$this->assertEquals(0, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// Unmuting a conversation which is already unmuted.
|
||||
$return = core_message_external::unmute_conversations($user1->id, [$conversation->id]);
|
||||
$return = external_api::clean_returnvalue(core_message_external::unmute_conversations_returns(), $return);
|
||||
$this->assertEquals(array(), $return);
|
||||
|
||||
$this->assertEquals(0, $DB->count_records('message_conversation_actions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unmuting a conversation with messaging disabled.
|
||||
*/
|
||||
public function test_unmute_conversation_messaging_disabled() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create some skeleton data just so we can call the WS.
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$this->setUser($user1);
|
||||
|
||||
// Disable messaging.
|
||||
$CFG->messaging = 0;
|
||||
|
||||
// Ensure an exception is thrown.
|
||||
$this->expectException('moodle_exception');
|
||||
core_message_external::unmute_conversations($user1->id, [$user2->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unmuting a conversation with no permission.
|
||||
*/
|
||||
public function test_unmute_conversation_no_permission() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create some skeleton data just so we can call the WS.
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
$user3 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
|
||||
$this->setUser($user3);
|
||||
|
||||
// Ensure an exception is thrown.
|
||||
$this->expectException('required_capability_exception');
|
||||
core_message_external::unmute_conversations($user1->id, [$conversation->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test blocking a user.
|
||||
*/
|
||||
|
@ -5654,6 +5816,55 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
|
|||
$this->assertNotEmpty($individualmember['contactrequests']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test verifying get_conversations identifies if a conversation is muted or not.
|
||||
*/
|
||||
public function test_get_conversations_some_muted() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create some users.
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user2 = self::getDataGenerator()->create_user();
|
||||
$user3 = self::getDataGenerator()->create_user();
|
||||
|
||||
$conversation1 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user2->id]);
|
||||
testhelper::send_fake_message_to_conversation($user1, $conversation1->id, 'Message 1');
|
||||
testhelper::send_fake_message_to_conversation($user2, $conversation1->id, 'Message 2');
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
|
||||
$conversation2 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL,
|
||||
[$user1->id, $user3->id]);
|
||||
testhelper::send_fake_message_to_conversation($user1, $conversation2->id, 'Message 1');
|
||||
testhelper::send_fake_message_to_conversation($user2, $conversation2->id, 'Message 2');
|
||||
|
||||
$conversation3 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP,
|
||||
[$user1->id, $user2->id]);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation3->id);
|
||||
|
||||
$conversation4 = \core_message\api::create_conversation(\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP,
|
||||
[$user1->id, $user3->id]);
|
||||
|
||||
$this->setUser($user1);
|
||||
$result = core_message_external::get_conversations($user1->id);
|
||||
$result = external_api::clean_returnvalue(core_message_external::get_conversations_returns(), $result);
|
||||
$conversations = $result['conversations'];
|
||||
|
||||
usort($conversations, function($first, $second){
|
||||
return $first['id'] > $second['id'];
|
||||
});
|
||||
|
||||
$conv1 = array_shift($conversations);
|
||||
$conv2 = array_shift($conversations);
|
||||
$conv3 = array_shift($conversations);
|
||||
$conv4 = array_shift($conversations);
|
||||
|
||||
$this->assertTrue($conv1['ismuted']);
|
||||
$this->assertFalse($conv2['ismuted']);
|
||||
$this->assertTrue($conv3['ismuted']);
|
||||
$this->assertFalse($conv4['ismuted']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test returning members in a conversation with no contact requests.
|
||||
*/
|
||||
|
|
|
@ -47,7 +47,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$collection = new collection('core_message');
|
||||
$newcollection = provider::get_metadata($collection);
|
||||
$itemcollection = $newcollection->get_collection();
|
||||
$this->assertCount(9, $itemcollection);
|
||||
$this->assertCount(10, $itemcollection);
|
||||
|
||||
$messagestable = array_shift($itemcollection);
|
||||
$this->assertEquals('messages', $messagestable->get_name());
|
||||
|
@ -58,6 +58,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$messageconversationmemberstable = array_shift($itemcollection);
|
||||
$this->assertEquals('message_conversation_members', $messageconversationmemberstable->get_name());
|
||||
|
||||
$messageconversationactions = array_shift($itemcollection);
|
||||
$this->assertEquals('message_conversation_actions', $messageconversationactions->get_name());
|
||||
|
||||
$messagecontacts = array_shift($itemcollection);
|
||||
$this->assertEquals('message_contacts', $messagecontacts->get_name());
|
||||
|
||||
|
@ -1584,6 +1587,10 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
\core_message\api::set_favourite_conversation($conversation1->id, $user1->id);
|
||||
\core_message\api::set_favourite_conversation($iconversation1id, $user2->id);
|
||||
|
||||
// Mute some conversations.
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
\core_message\api::mute_conversation($user2->id, $iconversation1id);
|
||||
|
||||
// Send some messages to the conversation.
|
||||
$m1 = testhelper::send_fake_message_to_conversation($user1, $conversation1->id, 'Message 1', $now + 1);
|
||||
$m2 = testhelper::send_fake_message_to_conversation($user1, $conversation1->id, 'Message 2', $now + 2);
|
||||
|
@ -1646,6 +1653,15 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(transform::datetime($now + 5), $m3->timeread);
|
||||
$this->assertArrayNotHasKey('timedeleted', (array) $m3);
|
||||
|
||||
// Confirm the muted group conversation is correct.
|
||||
$mutedconversations = (array) $writer->get_related_data([
|
||||
get_string('messages', 'core_message'),
|
||||
get_string($conversation1->itemtype, $conversation1->component),
|
||||
get_string('privacy:export:conversationprefix', 'core_message') . $conversation1->name
|
||||
], 'muted');
|
||||
$this->assertCount(2, $mutedconversations);
|
||||
$this->assertEquals(get_string('yes'), $mutedconversations['muted']);
|
||||
|
||||
// Confirm the favourite group conversation is correct.
|
||||
$favourite = (array) $writer->get_related_data([
|
||||
get_string('messages', 'core_message'),
|
||||
|
@ -1707,6 +1723,14 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals('-', $m3->timeread);
|
||||
$this->assertArrayNotHasKey('timedeleted', (array) $m3);
|
||||
|
||||
// Confirm the muted group conversation is correct.
|
||||
$mutedconversations = (array) $writer->get_related_data([
|
||||
get_string('messages', 'core_message'),
|
||||
get_string($conversation1->itemtype, $conversation1->component),
|
||||
$conversation1->name
|
||||
], 'muted');
|
||||
$this->assertCount(0, $mutedconversations);
|
||||
|
||||
// Confirm there are no favourite group conversation for user2.
|
||||
$favourite = (array) $writer->get_related_data([
|
||||
get_string('messages', 'core_message'),
|
||||
|
@ -1822,6 +1846,11 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// Mark as read one of the conversation messages.
|
||||
\core_message\api::mark_message_as_read($user1->id, $dbgm3, $now + 5);
|
||||
|
||||
// Mark some conversations as muted by two users.
|
||||
\core_message\api::mute_conversation($user1->id, $iconversation1id);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
\core_message\api::mute_conversation($user2->id, $conversation1->id);
|
||||
|
||||
// There should be 2 contacts.
|
||||
$this->assertEquals(2, $DB->count_records('message_contacts'));
|
||||
|
||||
|
@ -1837,6 +1866,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// There should be 4 user actions - 3 for reading the message, 1 for deleting.
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
|
||||
// There should be 3 muted conversations.
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 4 conversations - 2 individual + 2 group.
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
|
||||
|
@ -1861,7 +1893,10 @@ 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 5 notifications.
|
||||
// There should be 1 muted conversation.
|
||||
$this->assertEquals(1, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 3 notifications.
|
||||
$this->assertEquals(5, $DB->count_records('notifications'));
|
||||
|
||||
// There should be 5 messages - 3 individual - 2 group (course2).
|
||||
|
@ -1992,6 +2027,11 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
|
||||
$dbgm3 = $DB->get_record('messages', ['id' => $gm3]);
|
||||
|
||||
// Mark some conversations as muted by two users.
|
||||
\core_message\api::mute_conversation($user1->id, $iconversation1id);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
\core_message\api::mute_conversation($user2->id, $conversation1->id);
|
||||
|
||||
// Mark as read one of the conversation messages.
|
||||
\core_message\api::mark_message_as_read($user1->id, $dbgm3, $now + 5);
|
||||
|
||||
|
@ -2010,6 +2050,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// There should be 4 user actions - 3 for reading the message, 1 for deleting.
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
|
||||
// There should be 3 muted conversations.
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 4 conversations - 2 individual + 2 group.
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
|
||||
|
@ -2031,6 +2074,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
|
||||
$this->assertEquals(8, $DB->count_records('messages'));
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_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'));
|
||||
|
@ -2045,6 +2089,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
|
||||
$this->assertEquals(8, $DB->count_records('messages'));
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_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'));
|
||||
|
@ -2154,6 +2199,11 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// Mark as read one of the conversation messages.
|
||||
\core_message\api::mark_message_as_read($user1->id, $dbgm3, $now + 5);
|
||||
|
||||
// Mark some of the conversations as muted by two users.
|
||||
\core_message\api::mute_conversation($user1->id, $iconversation1id);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
\core_message\api::mute_conversation($user2->id, $conversation1->id);
|
||||
|
||||
// There should be 2 contacts.
|
||||
$this->assertEquals(2, $DB->count_records('message_contacts'));
|
||||
|
||||
|
@ -2169,6 +2219,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// There should be 4 user actions - 3 for reading the message, 1 for deleting.
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
|
||||
// There should be 3 muted conversations.
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 4 conversations - 2 individual + 2 group.
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
|
||||
|
@ -2190,6 +2243,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
|
||||
$this->assertEquals(8, $DB->count_records('messages'));
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_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'));
|
||||
|
@ -2204,6 +2258,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(2, $DB->count_records('message_users_blocked'));
|
||||
$this->assertEquals(8, $DB->count_records('messages'));
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_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'));
|
||||
|
@ -2301,6 +2356,11 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// Mark as read one of the conversation messages.
|
||||
\core_message\api::mark_message_as_read($user1->id, $dbm3, $now + 5);
|
||||
|
||||
// Mark some of the conversations as muted by two users.
|
||||
\core_message\api::mute_conversation($user1->id, $iconversation1id);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
\core_message\api::mute_conversation($user2->id, $conversation1->id);
|
||||
|
||||
// There should be 2 contacts.
|
||||
$this->assertEquals(2, $DB->count_records('message_contacts'));
|
||||
|
||||
|
@ -2319,6 +2379,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// There should be 4 user actions - 3 for reading the message, one for deleting.
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
|
||||
// There should be 3 users muting a conversation.
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 3 conversations - 2 private + 1 group.
|
||||
$this->assertEquals(3, $DB->count_records('message_conversations'));
|
||||
|
||||
|
@ -2347,7 +2410,10 @@ 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 5 notifications.
|
||||
// There should be 2 muted conversation.
|
||||
$this->assertEquals(2, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 3 notifications.
|
||||
$this->assertEquals(5, $DB->count_records('notifications'));
|
||||
|
||||
// There should be 4 messages - 3 private + 1 group sent by user2.
|
||||
|
@ -2484,6 +2550,11 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// Mark as read one of the conversation messages.
|
||||
\core_message\api::mark_message_as_read($user1->id, $dbm3, $now + 5);
|
||||
|
||||
// Mark some of the conversations as muted by two users.
|
||||
\core_message\api::mute_conversation($user1->id, $iconversation1id);
|
||||
\core_message\api::mute_conversation($user1->id, $conversation1->id);
|
||||
\core_message\api::mute_conversation($user2->id, $conversation1->id);
|
||||
|
||||
// There should be 2 contacts.
|
||||
$this->assertEquals(2, $DB->count_records('message_contacts'));
|
||||
|
||||
|
@ -2502,6 +2573,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
// There should be 4 user actions - 3 for reading the message, one for deleting.
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
|
||||
// There should be 3 muted conversation.
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be 3 conversations - 2 private + 2 group.
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
|
||||
|
@ -2529,6 +2603,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(5, $DB->count_records('notifications'));
|
||||
$this->assertEquals(6, $DB->count_records('messages'));
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
$this->assertEquals(8, $DB->count_records('message_conversation_members'));
|
||||
$this->assertEquals(3, $DB->count_records('favourite'));
|
||||
|
@ -2545,6 +2620,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
$this->assertEquals(5, $DB->count_records('notifications'));
|
||||
$this->assertEquals(6, $DB->count_records('messages'));
|
||||
$this->assertEquals(4, $DB->count_records('message_user_actions'));
|
||||
$this->assertEquals(3, $DB->count_records('message_conversation_actions'));
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
$this->assertEquals(3, $DB->count_records('favourite'));
|
||||
// There should be 7 conversation members - (2 + 2) private + 3 group.
|
||||
|
@ -2583,6 +2659,9 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
|
|||
}, $useractions);
|
||||
$this->assertNotContains($gm3, $useractions);
|
||||
|
||||
// There should be 1 muted conversation.
|
||||
$this->assertEquals(1, $DB->count_records('message_conversation_actions'));
|
||||
|
||||
// There should be still 4 conversations - 2 private + 2 group.
|
||||
$this->assertEquals(4, $DB->count_records('message_conversations'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue