@@ -22,16 +22,6 @@ public function it_validates_and_filters_notification_recipients()
22
22
$ this ->assertNotInstanceOf (SwiftMailerHandler::class, $ handler );
23
23
}
24
24
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
-
35
25
/** @test */
36
26
public function it_uses_configured_monolog_swift_mailer_handler_on_mail_driver ()
37
27
{
@@ -62,20 +52,10 @@ public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driv
62
52
$ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
63
53
}
64
54
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
-
75
55
/** @test */
76
56
public function it_uses_configured_monolog_deduplication_handler_if_deduplication_enabled ()
77
57
{
78
- config (['mail.driver ' => 'any-other ' ]);
58
+ config (['mail.driver ' => 'sendmail ' ]);
79
59
80
60
/** @var \Monolog\Handler\DeduplicationHandler $handler */
81
61
$ handler = $ this ->runArtisan (new EmailNotificationsDeduplicationCommand )->emailChannelHandler ();
@@ -87,43 +67,18 @@ public function it_uses_configured_monolog_deduplication_handler_if_deduplicatio
87
67
/**
88
68
* Compose "swift mailer" handler.
89
69
*
70
+ * @param string $name
90
71
* @return \Monolog\Handler\SwiftMailerHandler
91
72
*/
92
- private function composeSwiftMailerHandler ()
73
+ private function composeSwiftMailerHandler ($ name = ' email-notifications-command ' )
93
74
{
94
- $ handler = new SwiftMailerHandler (app ('swift.mailer ' ), $ this ->composeMailerHandlerMessage (), Logger::NOTICE );
75
+ $ handler = new SwiftMailerHandler (app ('swift.mailer ' ), $ this ->composeMailerHandlerMessage ($ name ), Logger::NOTICE );
95
76
96
77
$ handler ->setFormatter (new MonologHtmlFormatter );
97
78
98
79
return $ handler ;
99
80
}
100
81
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 ' => 'john.doe@example.com ' , 'name ' => 'John Doe ' ],
112
- ['address ' => 'jane.smith@example.com ' , 'name ' => 'Jane Smith ' ],
113
- ]),
114
- "[TESTING] %level_name% in ` {$ name }` command " ,
115
- to_rfc2822_email ([
116
- 'address ' => 'no-reply@example.com ' ,
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
-
127
82
/**
128
83
* Compose "deduplication" handler.
129
84
*
@@ -132,20 +87,21 @@ private function composeNativeMailerHandler(string $name = 'email-notifications-
132
87
private function composeDeduplicationHandler ()
133
88
{
134
89
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
136
91
);
137
92
}
138
93
139
94
/**
140
95
* Compose mailer handler message.
141
96
*
97
+ * @param string $name
142
98
* @return \Swift_Message
143
99
*/
144
- private function composeMailerHandlerMessage ()
100
+ private function composeMailerHandlerMessage ($ name = ' email-notifications-command ' )
145
101
{
146
102
/** @var Swift_Message $message */
147
103
$ 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 " );
149
105
$ message ->setFrom (to_swiftmailer_emails ([
150
106
'address ' => 'no-reply@example.com ' ,
151
107
'name ' => 'ICLogger Notification ' ,
0 commit comments