diff --git a/tests/tool_deletemessage.php b/tests/tool_deletemessage.php index 04b2300..94a1499 100644 --- a/tests/tool_deletemessage.php +++ b/tests/tool_deletemessage.php @@ -1,38 +1,59 @@ dirroot.'/admin/tool/deletemessage/locallib.php'); - $user_from = $this->getDataGenerator()->create_user(); - $user_to = $this->getDataGenerator()->create_user(); + $userfrom = $this->getDataGenerator()->create_user(); + $userto = $this->getDataGenerator()->create_user(); - // Message text - $message_text = "hello"; + // Message text. + $messagetext = "hello"; - // Create message object + // Create message object. $message = new \core\message\message(); $message->component = 'core'; $message->name = 'instantmessage'; - $message->userfrom = $user_from; - $message->userto = $user_to; + $message->userfrom = $userfrom; + $message->userto = $userto; $message->subject = ''; - $message->fullmessage = $message_text; + $message->fullmessage = $messagetext; $message->fullmessageformat = FORMAT_PLAIN; - $message->fullmessagehtml = $message_text; - $message->smallmessage = $message_text; + $message->fullmessagehtml = $messagetext; + $message->smallmessage = $messagetext; - // Send message + // Send message. $messageid = message_send($message); - $this->assertNotEmpty($DB->get_records('message',['id'=>$messageid])); + $this->assertNotEmpty($DB->get_records('message', ['id' => $messageid])); hard_delete_message($messageid); - $this->assertEmpty($DB->get_records('message',['id'=>$messageid])); + $this->assertEmpty($DB->get_records('message', ['id' => $messageid])); } + /** + * Test taks of delection to not delete all messages + * @return void + */ public function test_taks_isnotdeleting() { global $CFG,$DB; require_once($CFG->dirroot.'/admin/tool/deletemessage/locallib.php'); @@ -56,9 +77,9 @@ public function test_taks_isnotdeleting() { // Send message $messageid = message_send($message); - $this->assertNotEmpty($DB->get_records('message',['id'=>$messageid])); $cron = new \tool_deletemessage\task\delete(); $cron->execute(); - $this->assertNotEmpty($DB->get_records('message',['id'=>$messageid])); + $this->assertNotEmpty($DB->get_records('message', ['id' => $messageid])); + $this->assertNotEmpty($DB->get_records('message')); } -} \ No newline at end of file +}