You are here

public function SwiftMailerAlterTest::testKeepOriginalPlainTextVersion in Swift Mailer 8

Same name and namespace in other branches
  1. 8.2 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 99

Class

SwiftMailerAlterTest
@group swiftmailer

Namespace

Drupal\Tests\swiftmailer\Functional

Code

public function testKeepOriginalPlainTextVersion() {
  $plugin = Drupal\swiftmailer\Plugin\Mail\SwiftMailer::create(\Drupal::getContainer(), [], NULL, NULL);
  $message = [
    'module' => 'swiftmailer_test',
    'key' => 'swiftmailer_test_1',
    'headers' => [
      'Content-Type' => SWIFTMAILER_FORMAT_HTML,
    ],
    'params' => [
      'convert' => FALSE,
    ],
    'subject' => 'Subject',
    'plain' => 'Original Plain Text Version',
    'body' => [
      Drupal\Core\Render\Markup::create('<strong>Hello World</strong>'),
    ],
  ];
  $message = $plugin
    ->format($message);
  $this
    ->assertContains('<strong>Hello World</strong>', (string) $message['body']);
  $this
    ->assertContains('Original Plain Text Version', $message['plain']);
}