Test that message sending may be canceled.
public function testCancelMessage() {
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
// Reset the class variable holding a copy of the last sent message.
self::$sent_message = NULL;
// Send a test message that simpletest_mail_alter should cancel.
$message = drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->langcode);
// Assert that the message was not actually sent.
$this
->assertNull(self::$sent_message, 'Message was canceled.');
}