MDL-65566 core_message: let get_self_conversation use lazy init too
authorJake Dallimore <jake@moodle.com>
Wed, 15 May 2019 10:28:15 +0000 (18:28 +0800)
committerJake Dallimore <jake@moodle.com>
Wed, 15 May 2019 10:46:41 +0000 (18:46 +0800)
message/classes/api.php
message/tests/api_test.php

index 1af93dc..a47abea 100644 (file)
@@ -2454,6 +2454,7 @@ class api {
      */
     public static function get_self_conversation(int $userid) {
         global $DB;
+        self::lazy_create_self_conversation($userid);
 
         $conditions = [
             'type' => self::MESSAGE_CONVERSATION_TYPE_SELF,
index 235ad5f..bc63342 100644 (file)
@@ -827,8 +827,9 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
         $this->assertEquals($user2->id, $member->id);
 
         \core_message\api::delete_all_conversation_data($rsc3->id);
-        $rsc3 = \core_message\api::get_self_conversation($user3->id);
-        $this->assertFalse($rsc3);
+        $selfconversation = \core_message\api::get_self_conversation($user3->id);
+        $members = \core_message\api::get_conversation_members($user1->id, $selfconversation->id);
+        $this->assertCount(1, $members);
     }
 
     /**