forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-66266 core_message: Final deprecation of 3.8 api functions
Final deprecation of: - can_post_message - get_individual_conversations_between_users
- Loading branch information
Showing
3 changed files
with
15 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
* @copyright 2016 Mark Nelson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class core_message_api_testcase extends core_message_messagelib_testcase { | ||
class core_message_api_test extends core_message_messagelib_testcase { | ||
|
||
public function test_mark_all_read_for_user_touser() { | ||
$sender = $this->getDataGenerator()->create_user(array('firstname' => 'Test1', 'lastname' => 'User1')); | ||
|
@@ -3265,26 +3265,6 @@ public function test_can_send_message_even_if_blocked_shared_course_with_message | |
$this->assertTrue(\core_message\api::can_send_message($student->id, $teacher->id, true)); | ||
} | ||
|
||
/** | ||
* Test that calling to can_post_message() now shows debugging. MDL-65093. | ||
* | ||
* @deprecated since 3.8 | ||
* @todo Final deprecation in MDL-66266 | ||
*/ | ||
public function test_can_post_emits_debugging() { | ||
// Create some users. | ||
$user1 = self::getDataGenerator()->create_user(); | ||
$user2 = self::getDataGenerator()->create_user(); | ||
|
||
// Set as the first user. | ||
$this->setUser($user1); | ||
|
||
// With the default privacy setting, users can't message them. | ||
$this->assertFalse(\core_message\api::can_post_message($user2)); | ||
$this->assertDebuggingCalled('\core_message\api::can_post_message is deprecated, please use ' . | ||
'\core_message\api::can_send_message instead.', DEBUG_DEVELOPER); | ||
} | ||
|
||
/** | ||
* Verify the expected behaviour of the can_send_message_to_conversation() method for authenticated users with default settings. | ||
*/ | ||
|
@@ -5197,154 +5177,6 @@ public function test_update_conversation_name() { | |
); | ||
} | ||
|
||
|
||
/** | ||
* Test an empty array returned when no args given. | ||
*/ | ||
public function test_get_individual_conversations_between_users_no_user_sets() { | ||
$this->assertEmpty(\core_message\api::get_individual_conversations_between_users([])); | ||
$this->assertDebuggingCalled(); | ||
} | ||
|
||
/** | ||
* Test a conversation is not returned if there is none. | ||
*/ | ||
public function test_get_individual_conversations_between_users_no_conversation() { | ||
$generator = $this->getDataGenerator(); | ||
$user1 = $generator->create_user(); | ||
$user2 = $generator->create_user(); | ||
|
||
$this->assertEquals( | ||
[null], | ||
\core_message\api::get_individual_conversations_between_users([[$user1->id, $user2->id]]) | ||
); | ||
$this->assertDebuggingCalled(); | ||
} | ||
|
||
/** | ||
* Test the result set includes null if there is no conversation between users. | ||
*/ | ||
public function test_get_individual_conversations_between_users_partial_conversations() { | ||
$generator = $this->getDataGenerator(); | ||
$user1 = $generator->create_user(); | ||
$user2 = $generator->create_user(); | ||
$user3 = $generator->create_user(); | ||
$type = \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL; | ||
|
||
$conversation1 = \core_message\api::create_conversation($type, [$user1->id, $user2->id]); | ||
$conversation2 = \core_message\api::create_conversation($type, [$user1->id, $user3->id]); | ||
|
||
$results = \core_message\api::get_individual_conversations_between_users([ | ||
[$user1->id, $user2->id], | ||
[$user2->id, $user3->id], | ||
[$user1->id, $user3->id] | ||
]); | ||
$this->assertDebuggingCalled(); | ||
|
||
$result = array_map(function($result) { | ||
if ($result) { | ||
return $result->id; | ||
} else { | ||
return $result; | ||
} | ||
}, $results); | ||
|
||
$this->assertEquals( | ||
[$conversation1->id, null, $conversation2->id], | ||
$result | ||
); | ||
} | ||
|
||
/** | ||
* Test all conversations are returned if each set has a conversation. | ||
*/ | ||
public function test_get_individual_conversations_between_users_all_conversations() { | ||
$generator = $this->getDataGenerator(); | ||
$user1 = $generator->create_user(); | ||
$user2 = $generator->create_user(); | ||
$user3 = $generator->create_user(); | ||
$type = \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL; | ||
|
||
$conversation1 = \core_message\api::create_conversation($type, [$user1->id, $user2->id]); | ||
$conversation2 = \core_message\api::create_conversation($type, [$user2->id, $user3->id]); | ||
$conversation3 = \core_message\api::create_conversation($type, [$user1->id, $user3->id]); | ||
|
||
$results = \core_message\api::get_individual_conversations_between_users([ | ||
[$user1->id, $user2->id], | ||
[$user2->id, $user3->id], | ||
[$user1->id, $user3->id] | ||
]); | ||
$this->assertDebuggingCalled(); | ||
|
||
$result = array_map(function($result) { | ||
if ($result) { | ||
return $result->id; | ||
} else { | ||
return $result; | ||
} | ||
}, $results); | ||
|
||
$this->assertEquals( | ||
[$conversation1->id, $conversation2->id, $conversation3->id], | ||
$result | ||
); | ||
} | ||
|
||
/** | ||
* Test that the results are ordered to match the order of the parameters. | ||
*/ | ||
public function test_get_individual_conversations_between_users_ordering() { | ||
$generator = $this->getDataGenerator(); | ||
$user1 = $generator->create_user(); | ||
$user2 = $generator->create_user(); | ||
$user3 = $generator->create_user(); | ||
$type = \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL; | ||
|
||
$conversation1 = \core_message\api::create_conversation($type, [$user1->id, $user2->id]); | ||
$conversation2 = \core_message\api::create_conversation($type, [$user2->id, $user3->id]); | ||
$conversation3 = \core_message\api::create_conversation($type, [$user1->id, $user3->id]); | ||
|
||
$results = \core_message\api::get_individual_conversations_between_users([ | ||
[$user1->id, $user2->id], | ||
[$user2->id, $user3->id], | ||
[$user1->id, $user3->id] | ||
]); | ||
$this->assertDebuggingCalled(); | ||
|
||
$result = array_map(function($result) { | ||
if ($result) { | ||
return $result->id; | ||
} else { | ||
return $result; | ||
} | ||
}, $results); | ||
|
||
$this->assertEquals( | ||
[$conversation1->id, $conversation2->id, $conversation3->id], | ||
$result | ||
); | ||
|
||
$results = \core_message\api::get_individual_conversations_between_users([ | ||
[$user2->id, $user3->id], | ||
[$user1->id, $user2->id], | ||
[$user1->id, $user3->id] | ||
]); | ||
$this->assertDebuggingCalled(); | ||
|
||
$result = array_map(function($result) { | ||
if ($result) { | ||
return $result->id; | ||
} else { | ||
return $result; | ||
} | ||
}, $results); | ||
|
||
$this->assertEquals( | ||
[$conversation2->id, $conversation1->id, $conversation3->id], | ||
$result | ||
); | ||
} | ||
|
||
/** | ||
* Test returning members in a conversation with no contact requests. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters