public function RerouteEmailTestBase::assertEmailOriginallyTo in Reroute Email 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/RerouteEmailTestBase.php \Drupal\Tests\reroute_email\Functional\RerouteEmailTestBase::assertEmailOriginallyTo()
Assert whether the text "Originally to: @to_email" is found in email body.
This method should be used ONLY for emails that were rerouted.
Parameters
string $original_destination: (optional) The original email address to be found in rerouted email body. Defaults to $this->originalDestination if set to NULL.
7 calls to RerouteEmailTestBase::assertEmailOriginallyTo()
- ContactTest::testBasicNotification in tests/
src/ Functional/ ContactTest.php - Basic tests of email rerouting for emails sent through the Contact forms.
- DomainAllowlistedTest::testAllowedByDomain in tests/
src/ Functional/ DomainAllowlistedTest.php - Basic tests for the domain addresses from the allowed list.
- MailKeysTest::testMailKeysFilter in tests/
src/ Functional/ MailKeysTest.php - Test Reroute Email with mail keys filter.
- MultipleRecipientsTest::testMultipleRecipients in tests/
src/ Functional/ MultipleRecipientsTest.php - Test Reroute Email with multiple recipients.
- RerouteEmailTestBase::assertEmailReroutedFromTestForm in tests/
src/ Functional/ RerouteEmailTestBase.php - Submit test email form and assert rerouting.
File
- tests/
src/ Functional/ RerouteEmailTestBase.php, line 152
Class
- RerouteEmailTestBase
- Base test class for Reroute Email test cases.
Namespace
Drupal\Tests\reroute_email\FunctionalCode
public function assertEmailOriginallyTo($original_destination = NULL) {
// Check the most recent email.
$mails = $this
->getMails();
if (empty($mails)) {
$this
->assertTrue(FALSE, 'Email was not sent.');
return;
}
// Initialize $original_destination by default if no value is provided.
if (NULL === $original_destination) {
$original_destination = $this->originalDestination;
}
// Destination address can contain display name with symbols "<" and ">".
// So, we can't use $this->t() or FormattableMarkup here.
$search_for = sprintf('Originally to: %s', $original_destination);
// Search in mail body for "Originally to: $original_destination" string.
$mail_body = end($mails)['body'];
$this
->assertStringContainsString($search_for, $mail_body, 'Found the correct "Originally to" line in the body.');
}