public function SwiftMailerAlterTest::testPlainTextConfigurationSetting in Swift Mailer 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/SwiftMailerAlterTest.php \Drupal\Tests\swiftmailer\Functional\SwiftMailerAlterTest::testPlainTextConfigurationSetting()
File
- tests/
src/ Functional/ SwiftMailerAlterTest.php, line 109
Class
- SwiftMailerAlterTest
- @group swiftmailer
Namespace
Drupal\Tests\swiftmailer\FunctionalCode
public function testPlainTextConfigurationSetting() {
$this
->config('swiftmailer.message')
->set('content_type', SWIFTMAILER_FORMAT_HTML)
->set('generate_plain', TRUE)
->save();
$plugin = SwiftMailer::create(\Drupal::getContainer(), [], NULL, NULL);
// Empty plain text, generate from html.
$message = [
'module' => 'swiftmailer_test',
'key' => 'swiftmailer_test_1',
'subject' => 'Subject',
'body' => [
Markup::create('<strong>Hello World</strong>'),
],
];
$message = $plugin
->format($message);
$this
->assertStringContainsString('<strong>Hello World</strong>', (string) $message['body']);
$this
->assertEquals('HELLO WORLD', $message['plain']);
// Keep original plain text version.
$message = [
'module' => 'swiftmailer_test',
'key' => 'swiftmailer_test_1',
'subject' => 'Subject',
'plain' => 'Original Plain Text Version',
'body' => [
Markup::create('<strong>Hello World</strong>'),
],
];
$message = $plugin
->format($message);
$this
->assertStringContainsString('<strong>Hello World</strong>', (string) $message['body']);
$this
->assertEquals('Original Plain Text Version', $message['plain']);
}