You are here

function MailTestCase::testCancelMessage in Drupal 7

Test that message sending may be canceled.

See also

simpletest_mail_alter()

File

modules/simpletest/tests/mail.test, line 49
Test the Drupal mailing system.

Class

MailTestCase
@file Test the Drupal mailing system.

Code

function testCancelMessage() {
  global $language;

  // 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);

  // Assert that the message was not actually sent.
  $this
    ->assertNull(self::$sent_message, 'Message was canceled.');
}