public function test_mark_all_notifications_as_read() { global $DB; $this->resetAfterTest(true); $sender1 = $this->getDataGenerator()->create_user(); $sender2 = $this->getDataGenerator()->create_user(); $sender3 = $this->getDataGenerator()->create_user(); $recipient = $this->getDataGenerator()->create_user(); $this->setUser($recipient); $this->send_message($sender1, $recipient, 'Notification', 1); $this->send_message($sender1, $recipient, 'Notification', 1); $this->send_message($sender2, $recipient, 'Notification', 1); $this->send_message($sender2, $recipient, 'Notification', 1); $this->send_message($sender3, $recipient, 'Notification', 1); $this->send_message($sender3, $recipient, 'Notification', 1); core_message_external::mark_all_notifications_as_read($recipient->id, $sender1->id); $readnotifications = $DB->get_recordset('message_read', ['useridto' => $recipient->id]); $unreadnotifications = $DB->get_recordset('message', ['useridto' => $recipient->id]); $this->assertCount(2, $readnotifications); $this->assertCount(4, $unreadnotifications); core_message_external::mark_all_notifications_as_read($recipient->id, 0); $readnotifications = $DB->get_recordset('message_read', ['useridto' => $recipient->id]); $unreadnotifications = $DB->get_recordset('message', ['useridto' => $recipient->id]); $this->assertCount(6, $readnotifications); $this->assertCount(0, $unreadnotifications); }