@@ -24,13 +24,7 @@ protected function tearDown(): void
24
24
25
25
public function testMailableSetsRecipientsCorrectly ()
26
26
{
27
- Container::getInstance ()->instance ('mailer ' , new class
28
- {
29
- public function render ()
30
- {
31
- //
32
- }
33
- });
27
+ $ this ->stubMailer ();
34
28
35
29
$ mailable = new WelcomeMailableStub ;
36
30
$ mailable->
to (
'[email protected] ' );
@@ -114,13 +108,7 @@ public function render()
114
108
115
109
public function testMailableSetsCcRecipientsCorrectly ()
116
110
{
117
- Container::getInstance ()->instance ('mailer ' , new class
118
- {
119
- public function render ()
120
- {
121
- //
122
- }
123
- });
111
+ $ this ->stubMailer ();
124
112
125
113
$ mailable = new WelcomeMailableStub ;
126
114
$ mailable->
cc (
'[email protected] ' );
@@ -211,13 +199,7 @@ public function render()
211
199
212
200
public function testMailableSetsBccRecipientsCorrectly ()
213
201
{
214
- Container::getInstance ()->instance ('mailer ' , new class
215
- {
216
- public function render ()
217
- {
218
- //
219
- }
220
- });
202
+ $ this ->stubMailer ();
221
203
222
204
$ mailable = new WelcomeMailableStub ;
223
205
$ mailable->
bcc (
'[email protected] ' );
@@ -308,13 +290,7 @@ public function render()
308
290
309
291
public function testMailableSetsReplyToCorrectly ()
310
292
{
311
- Container::getInstance ()->instance ('mailer ' , new class
312
- {
313
- public function render ()
314
- {
315
- //
316
- }
317
- });
293
+ $ this ->stubMailer ();
318
294
319
295
$ mailable = new WelcomeMailableStub ;
320
296
$ mailable->
replyTo (
'[email protected] ' );
@@ -394,13 +370,7 @@ public function render()
394
370
395
371
public function testMailableSetsFromCorrectly ()
396
372
{
397
- Container::getInstance ()->instance ('mailer ' , new class
398
- {
399
- public function render ()
400
- {
401
- //
402
- }
403
- });
373
+ $ this ->stubMailer ();
404
374
405
375
$ mailable = new WelcomeMailableStub ;
406
376
$ mailable->
from (
'[email protected] ' );
@@ -630,13 +600,7 @@ public function testMailablePriorityGetsSent()
630
600
631
601
public function testMailableMetadataGetsSent ()
632
602
{
633
- Container::getInstance ()->instance ('mailer ' , new class
634
- {
635
- public function render ()
636
- {
637
- //
638
- }
639
- });
603
+ $ this ->stubMailer ();
640
604
641
605
$ view = m::mock (Factory::class);
642
606
@@ -671,13 +635,7 @@ public function render()
671
635
672
636
public function testMailableTagGetsSent ()
673
637
{
674
- Container::getInstance ()->instance ('mailer ' , new class
675
- {
676
- public function render ()
677
- {
678
- //
679
- }
680
- });
638
+ $ this ->stubMailer ();
681
639
682
640
$ view = m::mock (Factory::class);
683
641
@@ -829,13 +787,7 @@ public function toMailAttachment()
829
787
830
788
public function testHasAttachmentWithEnvelopeAttachments ()
831
789
{
832
- Container::getInstance ()->instance ('mailer ' , new class
833
- {
834
- public function render ()
835
- {
836
- //
837
- }
838
- });
790
+ $ this ->stubMailer ();
839
791
$ mailable = new class extends Mailable
840
792
{
841
793
public function envelope ()
@@ -1034,13 +986,7 @@ public function testItCanCheckForStorageBasedAttachments()
1034
986
1035
987
public function testAssertHasAttachment ()
1036
988
{
1037
- Container::getInstance ()->instance ('mailer ' , new class
1038
- {
1039
- public function render ()
1040
- {
1041
- //
1042
- }
1043
- });
989
+ $ this ->stubMailer ();
1044
990
1045
991
$ mailable = new class () extends Mailable
1046
992
{
@@ -1070,13 +1016,7 @@ public function build()
1070
1016
1071
1017
public function testAssertHasAttachedData ()
1072
1018
{
1073
- Container::getInstance ()->instance ('mailer ' , new class
1074
- {
1075
- public function render ()
1076
- {
1077
- //
1078
- }
1079
- });
1019
+ $ this ->stubMailer ();
1080
1020
1081
1021
$ mailable = new class () extends Mailable
1082
1022
{
@@ -1134,13 +1074,7 @@ public function build()
1134
1074
1135
1075
public function testAssertHasSubject ()
1136
1076
{
1137
- Container::getInstance ()->instance ('mailer ' , new class
1138
- {
1139
- public function render ()
1140
- {
1141
- //
1142
- }
1143
- });
1077
+ $ this ->stubMailer ();
1144
1078
1145
1079
$ mailable = new class () extends Mailable
1146
1080
{
@@ -1194,13 +1128,7 @@ public function testMailableHeadersGetSent()
1194
1128
1195
1129
public function testMailableAttributesInBuild ()
1196
1130
{
1197
- Container::getInstance ()->instance ('mailer ' , new class
1198
- {
1199
- public function render ()
1200
- {
1201
- //
1202
- }
1203
- });
1131
+ $ this ->stubMailer ();
1204
1132
1205
1133
$ mailable = new class () extends Mailable
1206
1134
{
@@ -1227,6 +1155,32 @@ public function build()
1227
1155
$ mailable ->assertHasMetadata ('user_id ' , 1 );
1228
1156
$ mailable ->assertHasSubject ('test subject ' );
1229
1157
}
1158
+
1159
+ public function testMailablesCanBeTapped ()
1160
+ {
1161
+ $ this ->stubMailer ();
1162
+
1163
+ $ mail = new WelcomeMailableStub ;
1164
+
1165
+ $ mail->
tap (
fn (
$ mailable) =>
$ mailable->
to (
'[email protected] ' ,
'Taylor Otwell ' ));
1166
+ $ mail ->tap (fn ($ mailable ) => $ mailable ->subject ('Test Subject! ' ));
1167
+
1168
+ $ mail ->tap (function ($ mailable ) {
1169
+ $ mailable->
assertTo (
'[email protected] ' )
1170
+ ->assertHasSubject ('Test Subject! ' );
1171
+ });
1172
+ }
1173
+
1174
+ protected function stubMailer ()
1175
+ {
1176
+ Container::getInstance ()->instance ('mailer ' , new class
1177
+ {
1178
+ public function render ()
1179
+ {
1180
+ //
1181
+ }
1182
+ });
1183
+ }
1230
1184
}
1231
1185
1232
1186
class MailableHeadersStub extends Mailable
0 commit comments