You are here

public function SwiftMailerAlterTest::testTemplatePreprocess in Swift Mailer 8.2

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

File

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

Class

SwiftMailerAlterTest
@group swiftmailer

Namespace

Drupal\Tests\swiftmailer\Functional

Code

public function testTemplatePreprocess() {
  \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 = [
    'content_type' => SWIFTMAILER_FORMAT_HTML,
  ];
  \Drupal::service('plugin.manager.mail')
    ->mail('swiftmailer_test', 'test-2', 'test@example.com', \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId(), $params);
  $this
    ->assertStringContainsString('string_from_template', (string) $this->logger
    ->dump()[0]['body']);
  $this
    ->assertStringContainsString('variable_from_preprocess', (string) $this->logger
    ->dump()[0]['body']);
}