You are here

public function SwiftMailerAlterTest::testKeepOriginalPlainTextVersion in Swift Mailer 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/SwiftMailerAlterTest.php \Drupal\Tests\swiftmailer\Functional\SwiftMailerAlterTest::testKeepOriginalPlainTextVersion()

Preserve original plain text, do not generate it from body.

File

tests/src/Functional/SwiftMailerAlterTest.php, line 85

Class

SwiftMailerAlterTest
@group swiftmailer

Namespace

Drupal\Tests\swiftmailer\Functional

Code

public function testKeepOriginalPlainTextVersion() {
  $plugin = SwiftMailer::create(\Drupal::getContainer(), [], NULL, NULL);
  $message = [
    'module' => 'swiftmailer_test',
    'key' => 'swiftmailer_test_1',
    'headers' => [
      'Content-Type' => SWIFTMAILER_FORMAT_HTML,
    ],
    'params' => [
      'generate_plain' => FALSE,
    ],
    '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']);
}