You are here

public function SwiftMailerAlterTest::testGeneratePlainTextVersion in Swift Mailer 8.2

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

Create plain text version from body.

File

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

Class

SwiftMailerAlterTest
@group swiftmailer

Namespace

Drupal\Tests\swiftmailer\Functional

Code

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