You are here

public function RerouteEmailMailKeysTest::testMailKeysFilter in Reroute Email 7

Test Reroute Email with mail keys filter.

File

./reroute_email.test, line 698
Test the Reroute Email module.

Class

RerouteEmailMailKeysTest
Test Reroute Email with mail keys filter.

Code

public function testMailKeysFilter() {

  // Configure to reroute all outgoing emails.
  $this
    ->configureRerouteEmail($this->rerouteDestination);

  // Submit a test email (should be rerouted).
  $this
    ->drupalPost('admin/config/development/reroute_email/test', array(
    'to' => $this->originalDestination,
  ), t('Send email'));

  // Check if the email was rerouted properly.
  $this
    ->assertEmailOriginallyTo($this->originalDestination);
  $this
    ->assertMail('to', $this->rerouteDestination, format_string('Email was properly rerouted to the email address: @destination.', array(
    '@destination' => $this->rerouteDestination,
  )));

  // Configure to reroute outgoing emails only from our test module.
  $this
    ->configureRerouteEmail(NULL, NULL, NULL, NULL, NULL, 'not_existed_module');

  // Submit a test email (should not be rerouted).
  $this
    ->drupalPost('admin/config/development/reroute_email/test', array(
    'to' => $this->originalDestination,
  ), t('Send email'));

  // Check if the email was not rerouted.
  $this
    ->assertMail('to', $this->originalDestination, format_string('Email was properly sent the email addresses: @destination.', array(
    '@destination' => $this->originalDestination,
  )));

  // Configure to reroute only outgoing emails from our test form.
  $this
    ->configureRerouteEmail(NULL, NULL, NULL, NULL, NULL, 'reroute_email_test_email_form');

  // Submit a test email (should be rerouted).
  $this
    ->drupalPost('admin/config/development/reroute_email/test', array(
    'to' => $this->originalDestination,
  ), t('Send email'));

  // Check if the email was rerouted properly.
  $this
    ->assertEmailOriginallyTo($this->originalDestination);
  $this
    ->assertMail('to', $this->rerouteDestination, format_string('Email was properly rerouted to the email address: @destination.', array(
    '@destination' => $this->rerouteDestination,
  )));

  // Configure to reroute outgoing emails only from our test module.
  $this
    ->configureRerouteEmail(NULL, NULL, NULL, NULL, NULL, 'reroute_email_test');
}