You are here

public function WebformScheduledEmailTranslationTest::testWebformScheduledEmailTranslation in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_scheduled_email/tests/src/Functional/WebformScheduledEmailTranslationTest.php \Drupal\Tests\webform_scheduled_email\Functional\WebformScheduledEmailTranslationTest::testWebformScheduledEmailTranslation()

Tests webform schedule email handler translation.

File

modules/webform_scheduled_email/tests/src/Functional/WebformScheduledEmailTranslationTest.php, line 25

Class

WebformScheduledEmailTranslationTest
Tests for webform scheduled email handler translation.

Namespace

Drupal\Tests\webform_scheduled_email\Functional

Code

public function testWebformScheduledEmailTranslation() {
  $webform_schedule = Webform::load('test_handler_scheduled_translate');

  /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $scheduled_manager */
  $scheduled_manager = \Drupal::service('webform_scheduled_email.manager');

  /**************************************************************************/

  // Scheduled English email.
  $this
    ->drupalPostForm('/webform/' . $webform_schedule
    ->id(), [], 'Submit');

  // Send email.
  $scheduled_manager
    ->cron();

  // Check that scheduled English email as sent in English.
  $sent_email = $this
    ->getLastEmail();
  $this
    ->assertEqual($sent_email['subject'], 'English Subject');
  $this
    ->assertEqual($sent_email['body'], 'English Body' . PHP_EOL);

  // Scheduled Spanish email.
  $this
    ->drupalPostForm('/es/webform/' . $webform_schedule
    ->id(), [], 'Submit');

  // Send email.
  $scheduled_manager
    ->cron();

  // Check that scheduled Spanish email as sent in Spanish.
  $sent_email = $this
    ->getLastEmail();
  $this
    ->assertEqual($sent_email['subject'], 'Spanish Subject');
  $this
    ->assertEqual($sent_email['body'], 'Spanish Body' . PHP_EOL);
}