You are here

public function RerouteEmailDomainWhitelistedTestCase::testDomainWhitelistedEmail in Reroute Email 7

Basic tests for the domain whitelisted addresses.

File

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

Class

RerouteEmailDomainWhitelistedTestCase
Test Reroute Email's with a domain whitelisted.

Code

public function testDomainWhitelistedEmail() {

  // Set rerouting email and whitelisted domain.
  $this
    ->configureRerouteEmail($this->rerouteDestination, $this->whitelistedDomain);

  // Make sure configured emails were set.
  $this
    ->assertEqual(variable_get(REROUTE_EMAIL_ADDRESS), $this->rerouteDestination, 'Reroute email address was set.');
  $this
    ->assertEqual(variable_get(REROUTE_EMAIL_WHITELIST), $this->whitelistedDomain, 'Whitelisted value was set.');

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

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

  // 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 rerouted properly.
  $this
    ->assertMail('to', $this->originalDestination, format_string('Email was properly sent the email address: @destination.', array(
    '@destination' => $this->originalDestination,
  )));
}