public function MailHandlerThemeTest::testCustomTheme in Commerce Core 8.2
Tests the email with custom theme.
File
- tests/
src/ Kernel/ MailHandlerThemeTest.php, line 85
Class
- MailHandlerThemeTest
- Tests sending emails using the MailSystem mail theme setting.
Namespace
Drupal\Tests\commerce\KernelCode
public function testCustomTheme() {
$mailsystem_config = $this
->config('mailsystem.settings');
$mailsystem_config
->set('defaults.sender', 'test_mail_collector')
->set('defaults.formatter', 'test_mail_collector')
->set('theme', 'commerce_test_theme')
->save();
$body = [
'#theme' => 'username',
'#account' => $this->user,
];
$this->mailHandler
->sendMail($this->user
->getEmail(), 'Hello, customer!', $body);
$emails = $this
->getMails();
$this
->assertEquals(1, count($emails));
$email = reset($emails);
$this
->assertEquals('text/html; charset=UTF-8;', $email['headers']['Content-Type']);
$this
->assertEquals('commerce_mail', $email['id']);
$this
->assertEquals($this->user
->getEmail(), $email['to']);
$this
->assertFalse(isset($email['headers']['Bcc']));
$this
->assertEquals($this->store
->getEmail(), $email['from']);
$this
->assertEquals('Hello, customer!', $email['subject']);
$this
->assertStringContainsString('Commerce test theme', $email['body']);
}