MDL-64993 core_message: fix unit test for non-ordered queries

This commit is contained in:
Amaia Anabitarte
2019-05-07 17:54:43 +02:00
committed by Sara Arjona
parent 48c8a555e0
commit e4987f0f58
4 changed files with 15 additions and 13 deletions
+5 -7
View File
@@ -716,14 +716,12 @@ class core_group_privacy_provider_testcase extends provider_testcase {
// User1 is member of some groups in course1 and course2 + self-conversation.
$contextlist = provider::get_contexts_for_userid($user1->id);
$contextids = $contextlist->get_contextids();
// First user context is the one related to self-conversation. Let's test group contexts.
array_pop($contextids);
$contextids = array_values($contextlist->get_contextids());
$this->assertCount(3, $contextlist);
$this->assertEquals(
[$coursecontext1->id, $coursecontext2->id],
$contextids,
'', 0.0, 10, true);
// One of the user context is the one related to self-conversation. Let's test group contexts.
$this->assertContains($coursecontext1->id, $contextids);
$this->assertContains($coursecontext2->id, $contextids);
}
/**
+5 -3
View File
@@ -1766,10 +1766,12 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Now, get ONLY favourite conversations (including self-conversation).
$conversations = \core_message\api::get_conversations($user1->id, 0, 20, null, true);
$this->assertCount(2, $conversations);
$self = array_pop($conversations);
foreach ($conversations as $conv) {
$this->assertTrue($conv->isfavourite);
$this->assertEquals($ic2->id, $conv->id);
if ($conv->type != \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF) {
$this->assertTrue($conv->isfavourite);
$this->assertEquals(\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL, $conv->type);
$this->assertEquals($ic2->id, $conv->id);
}
}
// Now, try ONLY favourites of type 'group'.
+1 -1
View File
@@ -2811,7 +2811,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
$users[$i] = $user;
}
// Enrol the first 9 users in the same course, but leave them as non-contacts.
// Enrol the first 8 users in the same course, but leave them as non-contacts.
$this->setAdminUser();
$course1 = $this->getDataGenerator()->create_course();
foreach (range(1, 8) as $i) {
+4 -2
View File
@@ -1133,8 +1133,10 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
$this->assertCount(0, $muas);
$this->assertCount(6, $mcms);
$mcm = reset($mcms);
$this->assertEquals($user2->id, $mcm->userid);
$members = array_map(function($member) {
return $member->userid;
}, $mcms);
$this->assertContains($user2->id, $members);
$this->assertCount(2, $notifications);
ksort($notifications);