public function test_no_messages() { global $USER; $actual = local::get_user_messages($USER->id); $expected = array(); $this->assertSame($actual, $expected); $actual = local::messages(); $expected = '<p>You have no messages.</p>'; $this->assertSame($actual, $expected); }
public function test_one_message_user_deleted() { $this->resetAfterTest(); $generator = $this->getDataGenerator(); $userfrom = $generator->create_user(); $userto = $generator->create_user(); $message = new \core\message\message(); $message->component = 'moodle'; $message->name = 'instantmessage'; $message->userfrom = $userfrom; $message->userto = $userto; $message->subject = 'message subject 1'; $message->fullmessage = 'message body'; $message->fullmessageformat = FORMAT_MARKDOWN; $message->fullmessagehtml = '<p>message body</p>'; $message->smallmessage = 'small message'; $message->notification = '0'; message_send($message); $actual = local::get_user_messages($userfrom->id); $this->assertCount(0, $actual); $actual = local::get_user_messages($userto->id); $this->assertCount(1, $actual); delete_user($userfrom); $actual = local::get_user_messages($userto->id); $this->assertCount(0, $actual); }