public function MailTest::testLongSubject in Maillog / Mail Developer 8
Confirm what happens with long subject lines.
File
- tests/
src/ Kernel/ MailTest.php, line 85
Class
- MailTest
- Tests the maillog plugin.
Namespace
Drupal\Tests\maillog\KernelCode
public function testLongSubject() {
// Send an email.
$from_email = 'from_test@example.com';
$to_email = 'to_test@example.com';
\Drupal::service('plugin.manager.mail')
->mail('maillog_test', 'maillog_long_subject_test', $to_email, 'en', [], $from_email);
// Compare the maillog db entry with the sent mail.
$logged_email = $this
->getLatestMaillogEntry();
$this
->assertTrue(!empty($logged_email), 'The test email was captured.');
// The original subject line, as copied from maillog_test_mail().
$subject = str_repeat('Test email subject ', 20);
// Duplicate the string trimming.
$subject_trimmed = mb_substr($subject, 0, 255);
self::assertEquals($subject_trimmed, $logged_email['subject'], 'Email subject was trimmed correctly.');
self::assertNotEquals($subject, $logged_email['subject'], 'Email subject is not untrimmed.');
}