DomainWhitelistedTest.php in Reroute Email 8
File
tests/src/Functional/DomainWhitelistedTest.php
View source
<?php
namespace Drupal\Tests\reroute_email\Functional;
use Drupal\Component\Render\FormattableMarkup;
class DomainWhitelistedTest extends RerouteEmailTestBase {
public function testDomainWhitelistedEmail() {
$this
->configureRerouteEmail(TRUE, $this->rerouteDestination, $this->whitelistedDomain);
$this
->assertEqual($this->rerouteConfig
->get(REROUTE_EMAIL_ADDRESS), $this->rerouteDestination, 'Reroute email address was set.');
$this
->assertEqual($this->rerouteConfig
->get(REROUTE_EMAIL_WHITELIST), $this->whitelistedDomain, 'Whitelisted value was set.');
$to = 'some@not-exist.domain';
$this
->drupalPostForm('admin/config/development/reroute_email/test', [
'to' => $to,
], t('Send email'));
$this
->assertEmailOriginallyTo($to);
$this
->assertMail('to', $this->rerouteDestination, new FormattableMarkup('Email was properly rerouted to the email address: @destination.', [
'@destination' => $this->rerouteDestination,
]));
$this
->drupalPostForm('admin/config/development/reroute_email/test', [
'to' => $this->originalDestination,
], t('Send email'));
$this
->assertMail('to', $this->originalDestination, new FormattableMarkup('Email was properly sent the email address: @destination.', [
'@destination' => $this->originalDestination,
]));
}
}