@@ -18,67 +18,78 @@ class EmailChannelTest extends TestCase
1818 /** @test */
1919 public function it_validates_and_filters_notification_recipients ()
2020 {
21- $ handler = $ this ->runArtisan (new EmailNotificationsInvalidRecipientsCommand )->emailChannelHandler ();
22- $ this ->assertNotInstanceOf (SwiftMailerHandler::class, $ handler );
21+ /** @var EmailNotificationsInvalidRecipientsCommand $command */
22+ $ command = $ this ->runArtisan (new EmailNotificationsInvalidRecipientsCommand );
23+ $ this ->assertNotInstanceOf (SwiftMailerHandler::class, $ command ->emailChannelHandler ());
2324 }
2425
2526 /** @test */
2627 public function it_is_disabled_on_null_driver ()
2728 {
2829 config (['mail.driver ' => 'null ' ]);
2930
30- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->createEmailChannelHandler ();
31+ /** @var EmailNotificationsCommand $command */
32+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
3133
32- $ this ->assertFalse ($ handler );
34+ $ this ->assertFalse ($ command -> createEmailChannelHandler () );
3335 }
3436
3537 /** @test */
3638 public function it_uses_configured_monolog_swift_mailer_handler_on_mail_driver ()
3739 {
3840 config (['mail.driver ' => 'mail ' ]);
3941
40- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
42+ /** @var EmailNotificationsCommand $command */
43+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
4144
42- $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
45+ $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ command -> emailChannelHandler () );
4346 }
4447
4548 /** @test */
4649 public function it_uses_configured_monolog_swift_mailer_handler_on_smtp_driver ()
4750 {
48- config (['mail.driver ' => 'smtp ' ]);
51+ config ([
52+ 'mail.driver ' => 'smtp ' ,
53+ 'mail.host ' => 'example.com ' ,
54+ 'mail.port ' => 123 ,
55+ ]);
4956
50- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
57+ /** @var EmailNotificationsCommand $command */
58+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
5159
52- $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
60+ $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ command -> emailChannelHandler () );
5361 }
5462
5563 /** @test */
5664 public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driver ()
5765 {
5866 config (['mail.driver ' => 'sendmail ' ]);
5967
60- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
68+ /** @var EmailNotificationsCommand $command */
69+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
6170
62- $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
71+ $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ command -> emailChannelHandler () );
6372 }
6473
6574 /** @test */
6675 public function it_uses_configured_monolog_native_mailer_handler_on_other_drivers ()
6776 {
6877 config (['mail.driver ' => 'any-other ' ]);
6978
70- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
79+ /** @var EmailNotificationsCommand $command */
80+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
7181
72- $ this ->assertMailerHandlersEqual ($ this ->composeNativeMailerHandler (), $ handler );
82+ $ this ->assertMailerHandlersEqual ($ this ->composeNativeMailerHandler (), $ command -> emailChannelHandler () );
7383 }
7484
7585 /** @test */
7686 public function it_uses_configured_monolog_deduplication_handler_if_deduplication_enabled ()
7787 {
7888 config (['mail.driver ' => 'any-other ' ]);
7989
80- /** @var \Monolog\Handler\DeduplicationHandler $handler */
81- $ handler = $ this ->runArtisan (new EmailNotificationsDeduplicationCommand )->emailChannelHandler ();
90+ /** @var EmailNotificationsDeduplicationCommand $command */
91+ $ command = $ this ->runArtisan (new EmailNotificationsDeduplicationCommand );
92+ $ handler = $ command ->emailChannelHandler ();
8293 $ handler ->flush ();
8394
8495 $ this ->assertMailerHandlersEqual ($ this ->composeDeduplicationHandler (), $ handler );
@@ -91,7 +102,7 @@ public function it_uses_configured_monolog_deduplication_handler_if_deduplicatio
91102 */
92103 private function composeSwiftMailerHandler ()
93104 {
94- $ handler = new SwiftMailerHandler (app ('swift. mailer ' ), $ this ->composeMailerHandlerMessage (), Logger::NOTICE );
105+ $ handler = new SwiftMailerHandler (app ('mailer ' )-> getSwiftMailer ( ), $ this ->composeMailerHandlerMessage (), Logger::NOTICE );
95106
96107 $ handler ->setFormatter (new MonologHtmlFormatter );
97108
@@ -144,7 +155,7 @@ private function composeDeduplicationHandler()
144155 private function composeMailerHandlerMessage ()
145156 {
146157 /** @var Swift_Message $message */
147- $ message = app ('swift. mailer ' )->createMessage ();
158+ $ message = app ('mailer ' )-> getSwiftMailer ( )->createMessage ();
148159 $ message ->setSubject ('[TESTING] %level_name% in `email-notifications-command` command ' );
149160 $ message ->setFrom (to_swiftmailer_emails ([
150161 'address ' => 'no-reply@example.com ' ,
0 commit comments