From a46f7200d7177c9a004df2962ea3431721ef5257 Mon Sep 17 00:00:00 2001 From: Robert Ragas Date: Tue, 22 Aug 2023 13:37:21 +0200 Subject: [PATCH] Fix the behat testing by adding the new mail log plugin to the test coverage --- .../src/Plugin/EmailAdjuster/LogMail.php | 2 +- tests/behat/features/bootstrap/EmailContext.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/social_features/social_mailer/src/Plugin/EmailAdjuster/LogMail.php b/modules/social_features/social_mailer/src/Plugin/EmailAdjuster/LogMail.php index f295e39e8f8..409229eec42 100644 --- a/modules/social_features/social_mailer/src/Plugin/EmailAdjuster/LogMail.php +++ b/modules/social_features/social_mailer/src/Plugin/EmailAdjuster/LogMail.php @@ -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."), diff --git a/tests/behat/features/bootstrap/EmailContext.php b/tests/behat/features/bootstrap/EmailContext.php index f003de6e2d5..3c96e37a516 100644 --- a/tests/behat/features/bootstrap/EmailContext.php +++ b/tests/behat/features/bootstrap/EmailContext.php @@ -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 { @@ -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(); }