-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seeEmailIsSent()
not working when email is sent by a Symfony/Doctrine entity listener
#5252
Comments
I've had the same issue trying to test emails sent from a doctrine entity listener. The only way I've found to get sent emails from profiler is to persist the <?php
namespace App\Tests\Helper;
class Symfony extends \Codeception\Module\Symfony
{
/**
* {@inheritdoc}
*/
public function _initialize()
{
parent::_initialize();
$this->persistService('swiftmailer.mailer.default.plugin.messagelogger', true);
}
} As far as I understand, Symfony and Doctrine doesn't share the same container when using both Symfony and Doctrine2 modules in codeception. Not sure it's the right solution, but it works for me. |
@TavoNiievez Do you have an idea for Symfony Mailer? |
@ThomasLandauer Can you confirm if after sending the email you do some kind of redirection? |
More details: The controller is an api, it just persists the incoming data, then: return new Response('OK'); // This is not packed in an HTML skeleton to prevent the Symfony toolbar from loading - but this shouldn't make a difference in TEST environment The entity listener kicks in In Codeception I'm doing: $I->sendPOST('/api/...');
$I->seeEmailIsSent(); And the error message I'm getting is:
The workaround I'm using right now: With Contrary to what I said above, I cannot get it to work anymore if I move the email sending code from the listener to the controller! So maybe the cause of the problem is that I'm using |
Closing this, as it was transferred to Codeception/module-symfony#90 |
When using an Entity Listener to send an email,
seeEmailIsSent()
doesn't notice it. When I do the same email command in the controller, it works.The actual email delivery works in both cases (as shown by mailcatcher).
Details
The text was updated successfully, but these errors were encountered: