View source
<?php
namespace Drupal\Tests\reroute_email\Functional;
use Drupal\Component\Render\FormattableMarkup;
class MultipleRecipientsTest extends RerouteEmailTestBase {
public function testMultipleRecipients() {
$this
->configureRerouteEmail(TRUE, 'user1@example.com, user2@example.com,;;,,user@example.com', $this->allowlistedDomain);
$reroute_to = 'user1@example.com,user2@example.com,user@example.com';
$this
->assertEquals($this->rerouteConfig
->get(REROUTE_EMAIL_ADDRESS), $reroute_to, 'Reroute email address was set.');
$this
->assertEquals($this->rerouteConfig
->get(REROUTE_EMAIL_ALLOWLIST), $this->allowlistedDomain, 'Value was set to the allowed list.');
$to = 'email@not-allowlisted.com, allowlisted@example.com';
$this
->drupalGet('admin/config/development/reroute_email/test');
$this
->submitForm([
'to' => $to,
], t('Send email'));
$this
->assertEmailOriginallyTo($to);
$this
->assertMail('to', $reroute_to, new FormattableMarkup('Email was properly rerouted to the email address: @destination.', [
'@destination' => $reroute_to,
]));
$to = 'allowlisted@example.com, user2@example.com, allowed@example.com';
$this
->drupalGet('admin/config/development/reroute_email/test');
$this
->submitForm([
'to' => $to,
], t('Send email'));
$this
->assertMail('to', $to, new FormattableMarkup('Email was properly sent the email addresses: @destination.', [
'@destination' => $to,
]));
}
}