Skip to content

Commit 5dac9c1

Browse files
Update Symfony.php
Fixing `seeEmailIsSent()` for [Symfony Mailer](https://symfony.com/doc/master/mailer.html) How did I figure it out (=Symfony internals): [`mailer_debug.php`](https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer_debug.php) sends the [`MessageDataCollector`](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Mailer/DataCollector/MessageDataCollector.php) to [`mailer.html.twig`](https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig#L9), which shows that the number of `events.messages` is the thing to look for. I'm just adding this number to the number returned by the SwiftMailer Collector. Limitations (=TODO): * I have both SwiftMailer and Symfony Mailer installed - don't know what happens if you only have one (or none) * I didn't add any tests - don't know how to do that
1 parent e60d426 commit 5dac9c1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Codeception/Module/Symfony.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ public function seeEmailIsSent($expectedCount = null)
498498
}
499499

500500
$realCount = $profile->getCollector('swiftmailer')->getMessageCount();
501+
$realCount += count($profile->getCollector('mailer')->getEvents()->getMessages());
501502
if ($expectedCount === null) {
502503
$this->assertGreaterThan(0, $realCount);
503504
} else {

0 commit comments

Comments
 (0)