You are here

public function SwiftMailerAlterTest::testTemplatePreprocess in Swift Mailer 8

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

File

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

Class

SwiftMailerAlterTest
@group swiftmailer

Namespace

Drupal\Tests\swiftmailer\Functional

Code

public function testTemplatePreprocess() {
  \Drupal::configFactory()
    ->getEditable('swiftmailer.message')
    ->set('respect_format', FALSE)
    ->save();
  \Drupal::configFactory()
    ->getEditable('system.theme')
    ->set('default', 'swiftmailer_test_theme')
    ->save();
  \Drupal::configFactory()
    ->getEditable('mailsystem.settings')
    ->set('theme', 'default')
    ->save();
  \Drupal::service('theme_installer')
    ->install([
    'swiftmailer_test_theme',
  ]);
  $params = [
    'format' => SWIFTMAILER_FORMAT_HTML,
  ];
  \Drupal::service('plugin.manager.mail')
    ->mail('swiftmailer_test', 'test-2', 'test@example.com', \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId(), $params);
  $this
    ->assertContains('string_from_template', (string) $this->logger
    ->dump()[0]['body']);
  $this
    ->assertContains('variable_from_preprocess', (string) $this->logger
    ->dump()[0]['body']);
}