You are here

public function EmailContext::enableEmailSpool in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  2. 8.3 tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  3. 8.4 tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  4. 8.5 tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  5. 8.6 tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  6. 8.8 tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  7. 10.3.x tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  8. 10.0.x tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  9. 10.1.x tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()
  10. 10.2.x tests/behat/features/bootstrap/EmailContext.php \Drupal\social\Behat\EmailContext::enableEmailSpool()

We need to enable the spool directory.

@BeforeScenario @email-spool

File

tests/behat/features/bootstrap/EmailContext.php, line 19

Class

EmailContext

Namespace

Drupal\social\Behat

Code

public function enableEmailSpool() {

  // Update Drupal configuration.
  $swiftmailer_config = \Drupal::configFactory()
    ->getEditable('swiftmailer.transport');
  $swiftmailer_config
    ->set('transport', 'spool');
  $swiftmailer_config
    ->set('spool_directory', $this
    ->getSpoolDir());
  $swiftmailer_config
    ->save();

  // Clean up emails that were left behind.
  $this
    ->purgeSpool();
}