From 8f84906cd1726f7db4cda47c08f1972afd1c57dc Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 15 Mar 2021 13:51:16 +0100 Subject: [PATCH 1/2] Explaining the stopFollowingRedirects() restriction for email See https://github.com/Codeception/module-symfony/pull/107#issuecomment-799069222 --- src/Codeception/Module/Symfony/MailerAssertionsTrait.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Codeception/Module/Symfony/MailerAssertionsTrait.php b/src/Codeception/Module/Symfony/MailerAssertionsTrait.php index d51769e2..7657d4ab 100644 --- a/src/Codeception/Module/Symfony/MailerAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/MailerAssertionsTrait.php @@ -20,10 +20,9 @@ public function dontSeeEmailIsSent(): void } /** - * Checks if the desired number of emails was sent. - * Asserts that 1 email was sent by default, specify the `expectedCount` parameter to modify it. - * The email is checked using Symfony message logger, which means: - * * If your app performs a redirect after sending the email, you need to suppress it using [stopFollowingRedirects](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects). + * Checks if the given number of emails was sent (default `$expectedCount`: 1). + * The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: + * If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first. * * ```php * fail("Emails can't be tested without Symfony Mailer service."); } -} \ No newline at end of file +} From 60ee0dced89afd9a6fecfcabd9219dcf3f2bb600 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 15 Mar 2021 17:04:55 +0100 Subject: [PATCH 2/2] Update MailerAssertionsTrait.php --- src/Codeception/Module/Symfony/MailerAssertionsTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Codeception/Module/Symfony/MailerAssertionsTrait.php b/src/Codeception/Module/Symfony/MailerAssertionsTrait.php index 7657d4ab..6940b01b 100644 --- a/src/Codeception/Module/Symfony/MailerAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/MailerAssertionsTrait.php @@ -13,6 +13,8 @@ trait MailerAssertionsTrait { /** * Checks that no email was sent. + * The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: + * If your app performs a HTTP redirect, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first; otherwise this check will *always* pass. */ public function dontSeeEmailIsSent(): void { @@ -38,6 +40,8 @@ public function seeEmailIsSent(int $expectedCount = 1): void /** * Returns the last sent email. + * The function is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: + * If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first. * * ```php *