1
1
<?php
2
2
3
3
use Illuminated \Console \Loggable \Notifications \EmailChannel \MonologHtmlFormatter ;
4
+ use Illuminated \Testing \InteractsWithConsole ;
4
5
use Monolog \Handler \DeduplicationHandler ;
5
6
use Monolog \Handler \MandrillHandler ;
6
7
use Monolog \Handler \NativeMailerHandler ;
9
10
10
11
class EmailChannelTest extends TestCase
11
12
{
13
+ use InteractsWithConsole;
14
+
12
15
/** @test */
13
16
public function it_validates_and_filters_notification_recipients ()
14
17
{
15
- $ handler = $ this ->runViaObject (EmailNotificationsInvalidRecipientsCommand::class)->mailerHandler ();
18
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsInvalidRecipientsCommand::class)->mailerHandler ();
16
19
$ this ->assertNotInstanceOf (SwiftMailerHandler::class, $ handler );
17
20
}
18
21
19
22
/** @test */
20
23
public function it_uses_configured_monolog_swift_mailer_handler_on_mail_driver ()
21
24
{
22
25
config (['mail.driver ' => 'mail ' ]);
23
- $ handler = $ this ->runViaObject (EmailNotificationsCommand::class)->mailerHandler ();
26
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsCommand::class)->mailerHandler ();
24
27
25
28
$ this ->assertMailerHandlersAreEqual ($ this ->composeSwiftMailerHandler (), $ handler );
26
29
}
@@ -29,7 +32,7 @@ public function it_uses_configured_monolog_swift_mailer_handler_on_mail_driver()
29
32
public function it_uses_configured_monolog_swift_mailer_handler_on_smtp_driver ()
30
33
{
31
34
config (['mail.driver ' => 'smtp ' ]);
32
- $ handler = $ this ->runViaObject (EmailNotificationsCommand::class)->mailerHandler ();
35
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsCommand::class)->mailerHandler ();
33
36
34
37
$ this ->assertMailerHandlersAreEqual ($ this ->composeSwiftMailerHandler (), $ handler );
35
38
}
@@ -38,7 +41,7 @@ public function it_uses_configured_monolog_swift_mailer_handler_on_smtp_driver()
38
41
public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driver ()
39
42
{
40
43
config (['mail.driver ' => 'sendmail ' ]);
41
- $ handler = $ this ->runViaObject (EmailNotificationsCommand::class)->mailerHandler ();
44
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsCommand::class)->mailerHandler ();
42
45
43
46
$ this ->assertMailerHandlersAreEqual ($ this ->composeSwiftMailerHandler (), $ handler );
44
47
}
@@ -47,7 +50,7 @@ public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driv
47
50
public function it_uses_configured_monolog_mandrill_mailer_handler_on_mandrill_driver ()
48
51
{
49
52
config (['mail.driver ' => 'mandrill ' , 'services.mandrill.secret ' => 'secret ' ]);
50
- $ handler = $ this ->runViaObject (EmailNotificationsCommand::class)->mailerHandler ();
53
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsCommand::class)->mailerHandler ();
51
54
52
55
$ this ->assertMailerHandlersAreEqual ($ this ->composeMandrillMailerHandler (), $ handler );
53
56
}
@@ -56,7 +59,7 @@ public function it_uses_configured_monolog_mandrill_mailer_handler_on_mandrill_d
56
59
public function it_uses_configured_monolog_native_mailer_handler_on_other_drivers ()
57
60
{
58
61
config (['mail.driver ' => 'any-other ' ]);
59
- $ handler = $ this ->runViaObject (EmailNotificationsCommand::class)->mailerHandler ();
62
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsCommand::class)->mailerHandler ();
60
63
61
64
$ this ->assertMailerHandlersAreEqual ($ this ->composeNativeMailerHandler (), $ handler );
62
65
}
@@ -65,7 +68,7 @@ public function it_uses_configured_monolog_native_mailer_handler_on_other_driver
65
68
public function it_uses_configured_monolog_deduplication_handler_if_deduplication_enabled ()
66
69
{
67
70
config (['mail.driver ' => 'any-other ' ]);
68
- $ handler = $ this ->runViaObject (EmailNotificationsDeduplicationCommand::class)->mailerHandler ();
71
+ $ handler = $ this ->runConsoleCommand (EmailNotificationsDeduplicationCommand::class)->mailerHandler ();
69
72
$ handler ->flush ();
70
73
71
74
$ this ->assertMailerHandlersAreEqual ($ this ->composeDeduplicationHandler (), $ handler );
0 commit comments