public static function assertMessage(local_mail_message $message)
 {
     global $DB;
     $course = $message->course();
     $record = $DB->get_record('local_mail_messages', array('id' => $message->id()));
     self::assertNotEquals(false, $record);
     self::assertEquals($course->id, $record->courseid);
     self::assertEquals($message->subject(), $record->subject);
     self::assertEquals($message->content(), $record->content);
     self::assertEquals($message->format(), $record->format);
     self::assertEquals($message->draft(), (bool) $record->draft);
     self::assertEquals($message->time(), $record->time);
     foreach ($message->references() as $reference) {
         self::assertRecords('message_refs', array('messageid' => $message->id(), 'reference' => $reference->id()));
     }
     $roleusers = array('from' => array($message->sender()), 'to' => $message->recipients('to'), 'cc' => $message->recipients('cc'), 'bcc' => $message->recipients('bcc'));
     foreach ($roleusers as $role => $users) {
         foreach ($users as $user) {
             self::assertRecords('message_users', array('messageid' => $message->id(), 'userid' => $user->id, 'role' => $role, 'unread' => (int) $message->unread($user->id), 'starred' => (int) $message->starred($user->id), 'deleted' => (int) $message->deleted($user->id)));
         }
     }
     foreach ($message->labels() as $label) {
         $conditions = array('messageid' => $message->id(), 'labelid' => $label->id());
         self::assertRecords('message_labels', $conditions);
     }
 }