Skip to content

Commit

Permalink
Fix the behat testing by adding the new mail log plugin to the test c…
Browse files Browse the repository at this point in the history
…overage
  • Loading branch information
Robert Ragas committed Aug 22, 2023
1 parent f77c952 commit a46f720
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Defines the file spool Mail Transport plugin.
*
* @MailerTransport(
* @EmailAdjuster(
* id = "log_mail",
* label = @Translation("Log Email"),
* description = @Translation("Saves emails to the file storage."),
Expand Down
13 changes: 9 additions & 4 deletions tests/behat/features/bootstrap/EmailContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\File\File;
use Drupal\symfony_mailer\Entity\MailerTransport;
use Drupal\symfony_mailer\Entity\MailerPolicy;

class EmailContext implements Context {

Expand All @@ -27,16 +28,20 @@ public function enableEmailSpool() {
$entity = MailerTransport::create([
'id' => 'behat_file_spool',
'label' => 'Behat File Spool',
'plugin' => 'file_spool',
'configuration' => [
'spool_directory' => $this->getSpoolDir(),
],
'plugin' => 'null',
]);
$entity->save();
}

$entity->setAsDefault();

// Add the mail logger plugin to the default policy.
$default_mailer_policy = MailerPolicy::load('_');
$mailer_configuration = $default_mailer_policy->getConfiguration();
$mailer_configuration['log_mail'] = ['spool_directory' => $this->getSpoolDir()];
$default_mailer_policy->setConfiguration($mailer_configuration);
$default_mailer_policy->save();

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

0 comments on commit a46f720

Please sign in to comment.