DomainAllowlistedTest.php in Reroute Email 2.x
File
tests/src/Functional/DomainAllowlistedTest.php
View source
<?php
namespace Drupal\Tests\reroute_email\Functional;
use Drupal\Component\Render\FormattableMarkup;
class DomainAllowlistedTest extends RerouteEmailTestBase {
public function testAllowedByDomain() {
$this
->configureRerouteEmail(TRUE, $this->rerouteDestination, $this->allowlistedDomain);
$this
->assertEquals($this->rerouteConfig
->get(REROUTE_EMAIL_ADDRESS), $this->rerouteDestination, 'Reroute email address was set.');
$this
->assertEquals($this->rerouteConfig
->get(REROUTE_EMAIL_ALLOWLIST), $this->allowlistedDomain, 'Value was set to allowed list.');
$to = 'some@not-exist.domain';
$this
->drupalGet('admin/config/development/reroute_email/test');
$this
->submitForm([
'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
->drupalGet('admin/config/development/reroute_email/test');
$this
->submitForm([
'to' => $this->originalDestination,
], t('Send email'));
$this
->assertMail('to', $this->originalDestination, new FormattableMarkup('Email was properly sent the email address: @destination.', [
'@destination' => $this->originalDestination,
]));
}
}