MDL-63547 core_message: updated api::can_delete_message

This commit is contained in:
Mark Nelson
2018-10-17 12:05:16 +08:00
parent 14de10c463
commit 08cb8a34f9
3 changed files with 51 additions and 21 deletions
+25
View File
@@ -2226,6 +2226,31 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
$this->assertTrue(\core_message\api::does_contact_request_exist($user2->id, $user1->id));
}
/**
* Test the user in conversation check.
*/
public function test_is_user_in_conversation() {
$user1 = self::getDataGenerator()->create_user();
$user2 = self::getDataGenerator()->create_user();
$conversationid = \core_message\api::create_conversation_between_users([$user1->id, $user2->id]);
$this->assertTrue(\core_message\api::is_user_in_conversation($user1->id, $conversationid));
}
/**
* Test the user in conversation check when they are not.
*/
public function test_is_user_in_conversation_when_not() {
$user1 = self::getDataGenerator()->create_user();
$user2 = self::getDataGenerator()->create_user();
$user3 = self::getDataGenerator()->create_user();
$conversationid = \core_message\api::create_conversation_between_users([$user1->id, $user2->id]);
$this->assertFalse(\core_message\api::is_user_in_conversation($user3->id, $conversationid));
}
/**
* Comparison function for sorting contacts.
*