@@ -479,15 +479,27 @@ public function seeInCurrentRoute($routeName)
479
479
* ```
480
480
*
481
481
* @param null|int $expectedCount
482
+ * @param null|string $mailer
482
483
*/
483
- public function seeEmailIsSent ($ expectedCount = null )
484
+ public function seeEmailIsSent ($ expectedCount = null , $ mailer = ' swiftmailer ' )
484
485
{
485
486
$ profile = $ this ->getProfile ();
486
487
if (!$ profile ) {
487
488
$ this ->fail ('Emails can \'t be tested without Profiler ' );
488
489
}
489
- if (!$ profile ->hasCollector ('swiftmailer ' )) {
490
- $ this ->fail ('Emails can \'t be tested without SwiftMailer connector ' );
490
+ switch ($ mailer ) {
491
+ case 'swiftmailer ' :
492
+ if (!$ profile ->hasCollector ('swiftmailer ' )) {
493
+ $ this ->fail ('Emails can \'t be tested without SwiftMailer connector ' );
494
+ }
495
+ break ;
496
+ case 'symfony_mailer ' :
497
+ if (!$ profile ->hasCollector ('mailer ' )) {
498
+ $ this ->fail ('Emails can \'t be tested without Symfony Mailer connector ' );
499
+ }
500
+ break ;
501
+ default :
502
+ $ this ->fail ('Invalid mailer argument. Allowed Options: "swiftmailer" or "symfony_mailer" ' );
491
503
}
492
504
493
505
if (!is_int ($ expectedCount ) && !is_null ($ expectedCount )) {
@@ -497,8 +509,12 @@ public function seeEmailIsSent($expectedCount = null)
497
509
));
498
510
}
499
511
500
- $ realCount = $ profile ->getCollector ('swiftmailer ' )->getMessageCount ();
501
- $ realCount += count ($ profile ->getCollector ('mailer ' )->getEvents ()->getMessages ());
512
+ if ($ mailer === 'swiftmailer ' ) {
513
+ $ realCount = $ profile ->getCollector ('swiftmailer ' )->getMessageCount ();
514
+ } else {
515
+ $ realCount = count ($ profile ->getCollector ('mailer ' )->getEvents ()->getMessages ());
516
+ }
517
+
502
518
if ($ expectedCount === null ) {
503
519
$ this ->assertGreaterThan (0 , $ realCount );
504
520
} else {
@@ -634,6 +650,11 @@ protected function debugResponse($url)
634
650
if ($ messages ) {
635
651
$ this ->debugSection ('Emails ' , $ messages . ' sent ' );
636
652
}
653
+ } elseif ($ profile ->hasCollector ('mailer ' )) {
654
+ $ messages = count ($ profile ->getCollector ('mailer ' )->getEvents ()->getMessages ());
655
+ if ($ messages ) {
656
+ $ this ->debugSection ('Emails ' , $ messages . ' sent ' );
657
+ }
637
658
}
638
659
if ($ profile ->hasCollector ('timer ' )) {
639
660
$ this ->debugSection ('Time ' , $ profile ->getCollector ('timer ' )->getTime ());
0 commit comments