@@ -22,16 +22,6 @@ public function it_validates_and_filters_notification_recipients()
2222 $ this ->assertNotInstanceOf (SwiftMailerHandler::class, $ handler );
2323 }
2424
25- /** @test */
26- public function it_is_disabled_on_null_driver ()
27- {
28- config (['mail.driver ' => 'null ' ]);
29-
30- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->createEmailChannelHandler ();
31-
32- $ this ->assertFalse ($ handler );
33- }
34-
3525 /** @test */
3626 public function it_uses_configured_monolog_swift_mailer_handler_on_mail_driver ()
3727 {
@@ -62,20 +52,10 @@ public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driv
6252 $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
6353 }
6454
65- /** @test */
66- public function it_uses_configured_monolog_native_mailer_handler_on_other_drivers ()
67- {
68- config (['mail.driver ' => 'any-other ' ]);
69-
70- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
71-
72- $ this ->assertMailerHandlersEqual ($ this ->composeNativeMailerHandler (), $ handler );
73- }
74-
7555 /** @test */
7656 public function it_uses_configured_monolog_deduplication_handler_if_deduplication_enabled ()
7757 {
78- config (['mail.driver ' => 'any-other ' ]);
58+ config (['mail.driver ' => 'sendmail ' ]);
7959
8060 /** @var \Monolog\Handler\DeduplicationHandler $handler */
8161 $ handler = $ this ->runArtisan (new EmailNotificationsDeduplicationCommand )->emailChannelHandler ();
@@ -87,43 +67,18 @@ public function it_uses_configured_monolog_deduplication_handler_if_deduplicatio
8767 /**
8868 * Compose "swift mailer" handler.
8969 *
70+ * @param string $name
9071 * @return \Monolog\Handler\SwiftMailerHandler
9172 */
92- private function composeSwiftMailerHandler ()
73+ private function composeSwiftMailerHandler ($ name = ' email-notifications-command ' )
9374 {
94- $ handler = new SwiftMailerHandler (app ('swift.mailer ' ), $ this ->composeMailerHandlerMessage (), Logger::NOTICE );
75+ $ handler = new SwiftMailerHandler (app ('swift.mailer ' ), $ this ->composeMailerHandlerMessage ($ name ), Logger::NOTICE );
9576
9677 $ handler ->setFormatter (new MonologHtmlFormatter );
9778
9879 return $ handler ;
9980 }
10081
101- /**
102- * Compose "native mailer" handler.
103- *
104- * @param string $name
105- * @return \Monolog\Handler\NativeMailerHandler
106- */
107- private function composeNativeMailerHandler (string $ name = 'email-notifications-command ' )
108- {
109- $ handler = new NativeMailerHandler (
110- to_rfc2822_email ([
111- [
'address ' =>
'[email protected] ' ,
'name ' =>
'John Doe ' ],
112- [
'address ' =>
'[email protected] ' ,
'name ' =>
'Jane Smith ' ],
113- ]),
114- "[TESTING] %level_name% in ` {$ name }` command " ,
115- to_rfc2822_email ([
116- 117- 'name ' => 'ICLogger Notification ' ,
118- ]),
119- Logger::NOTICE
120- );
121- $ handler ->setContentType ('text/html ' );
122- $ handler ->setFormatter (new MonologHtmlFormatter );
123-
124- return $ handler ;
125- }
126-
12782 /**
12883 * Compose "deduplication" handler.
12984 *
@@ -132,20 +87,21 @@ private function composeNativeMailerHandler(string $name = 'email-notifications-
13287 private function composeDeduplicationHandler ()
13388 {
13489 return new DeduplicationHandler (
135- $ this ->composeNativeMailerHandler ('email-notifications-deduplication-command ' ), null , Logger::NOTICE , 60
90+ $ this ->composeSwiftMailerHandler ('email-notifications-deduplication-command ' ), null , Logger::NOTICE , 60
13691 );
13792 }
13893
13994 /**
14095 * Compose mailer handler message.
14196 *
97+ * @param string $name
14298 * @return \Swift_Message
14399 */
144- private function composeMailerHandlerMessage ()
100+ private function composeMailerHandlerMessage ($ name = ' email-notifications-command ' )
145101 {
146102 /** @var Swift_Message $message */
147103 $ message = app ('swift.mailer ' )->createMessage ();
148- $ message ->setSubject (' [TESTING] %level_name% in `email-notifications-command ` command ' );
104+ $ message ->setSubject (" [TESTING] %level_name% in ` { $ name } ` command " );
149105 $ message ->setFrom (to_swiftmailer_emails ([
150106151107 'name ' => 'ICLogger Notification ' ,
0 commit comments