@@ -18,67 +18,78 @@ class EmailChannelTest extends TestCase
18
18
/** @test */
19
19
public function it_validates_and_filters_notification_recipients ()
20
20
{
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 ());
23
24
}
24
25
25
26
/** @test */
26
27
public function it_is_disabled_on_null_driver ()
27
28
{
28
29
config (['mail.driver ' => 'null ' ]);
29
30
30
- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->createEmailChannelHandler ();
31
+ /** @var EmailNotificationsCommand $command */
32
+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
31
33
32
- $ this ->assertFalse ($ handler );
34
+ $ this ->assertFalse ($ command -> createEmailChannelHandler () );
33
35
}
34
36
35
37
/** @test */
36
38
public function it_uses_configured_monolog_swift_mailer_handler_on_mail_driver ()
37
39
{
38
40
config (['mail.driver ' => 'mail ' ]);
39
41
40
- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
42
+ /** @var EmailNotificationsCommand $command */
43
+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
41
44
42
- $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
45
+ $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ command -> emailChannelHandler () );
43
46
}
44
47
45
48
/** @test */
46
49
public function it_uses_configured_monolog_swift_mailer_handler_on_smtp_driver ()
47
50
{
48
- config (['mail.driver ' => 'smtp ' ]);
51
+ config ([
52
+ 'mail.driver ' => 'smtp ' ,
53
+ 'mail.host ' => 'example.com ' ,
54
+ 'mail.port ' => 123 ,
55
+ ]);
49
56
50
- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
57
+ /** @var EmailNotificationsCommand $command */
58
+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
51
59
52
- $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
60
+ $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ command -> emailChannelHandler () );
53
61
}
54
62
55
63
/** @test */
56
64
public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driver ()
57
65
{
58
66
config (['mail.driver ' => 'sendmail ' ]);
59
67
60
- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
68
+ /** @var EmailNotificationsCommand $command */
69
+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
61
70
62
- $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ handler );
71
+ $ this ->assertMailerHandlersEqual ($ this ->composeSwiftMailerHandler (), $ command -> emailChannelHandler () );
63
72
}
64
73
65
74
/** @test */
66
75
public function it_uses_configured_monolog_native_mailer_handler_on_other_drivers ()
67
76
{
68
77
config (['mail.driver ' => 'any-other ' ]);
69
78
70
- $ handler = $ this ->runArtisan (new EmailNotificationsCommand )->emailChannelHandler ();
79
+ /** @var EmailNotificationsCommand $command */
80
+ $ command = $ this ->runArtisan (new EmailNotificationsCommand );
71
81
72
- $ this ->assertMailerHandlersEqual ($ this ->composeNativeMailerHandler (), $ handler );
82
+ $ this ->assertMailerHandlersEqual ($ this ->composeNativeMailerHandler (), $ command -> emailChannelHandler () );
73
83
}
74
84
75
85
/** @test */
76
86
public function it_uses_configured_monolog_deduplication_handler_if_deduplication_enabled ()
77
87
{
78
88
config (['mail.driver ' => 'any-other ' ]);
79
89
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 ();
82
93
$ handler ->flush ();
83
94
84
95
$ this ->assertMailerHandlersEqual ($ this ->composeDeduplicationHandler (), $ handler );
@@ -91,7 +102,7 @@ public function it_uses_configured_monolog_deduplication_handler_if_deduplicatio
91
102
*/
92
103
private function composeSwiftMailerHandler ()
93
104
{
94
- $ handler = new SwiftMailerHandler (app ('swift. mailer ' ), $ this ->composeMailerHandlerMessage (), Logger::NOTICE );
105
+ $ handler = new SwiftMailerHandler (app ('mailer ' )-> getSwiftMailer ( ), $ this ->composeMailerHandlerMessage (), Logger::NOTICE );
95
106
96
107
$ handler ->setFormatter (new MonologHtmlFormatter );
97
108
@@ -144,7 +155,7 @@ private function composeDeduplicationHandler()
144
155
private function composeMailerHandlerMessage ()
145
156
{
146
157
/** @var Swift_Message $message */
147
- $ message = app ('swift. mailer ' )->createMessage ();
158
+ $ message = app ('mailer ' )-> getSwiftMailer ( )->createMessage ();
148
159
$ message ->setSubject ('[TESTING] %level_name% in `email-notifications-command` command ' );
149
160
$ message ->setFrom (to_swiftmailer_emails ([
150
161
0 commit comments