@@ -167,6 +167,28 @@ public function attachments_are_added_to_the_email()
167
167
$ this ->assertEquals ('application/pdf ' , $ attachment ->getContentType ());
168
168
}
169
169
170
+ /** @test */
171
+ public function attachments_are_not_added_if_the_data_is_not_valid ()
172
+ {
173
+ $ this ->sent = [];
174
+ $ this ->composeEmail ()->attach (null )->send ();
175
+ $ this ->artisan ('email:send ' );
176
+ $ attachments = reset ($ this ->sent )->getMessage ()->getChildren ();
177
+ $ this ->assertCount (0 , $ attachments );
178
+
179
+ $ this ->sent = [];
180
+ $ this ->composeEmail ()->attach (false )->send ();
181
+ $ this ->artisan ('email:send ' );
182
+ $ attachments = reset ($ this ->sent )->getMessage ()->getChildren ();
183
+ $ this ->assertCount (0 , $ attachments );
184
+
185
+ $ this ->sent = [];
186
+ $ this ->composeEmail ()->attach ('' )->send ();
187
+ $ this ->artisan ('email:send ' );
188
+ $ attachments = reset ($ this ->sent )->getMessage ()->getChildren ();
189
+ $ this ->assertCount (0 , $ attachments );
190
+ }
191
+
170
192
/** @test */
171
193
public function raw_attachments_are_added_to_the_email ()
172
194
{
@@ -189,4 +211,26 @@ public function raw_attachments_are_added_to_the_email()
189
211
$ this ->assertEquals ('application/pdf ' , $ attachment ->getContentType ());
190
212
$ this ->assertContains ('Hello CI! ' , $ attachment ->getBody ());
191
213
}
214
+
215
+ /** @test */
216
+ public function raw_attachments_are_not_added_if_the_data_is_not_valid ()
217
+ {
218
+ $ this ->sent = [];
219
+ $ this ->composeEmail ()->attachData (null , 'test.png ' )->send ();
220
+ $ this ->artisan ('email:send ' );
221
+ $ attachments = reset ($ this ->sent )->getMessage ()->getChildren ();
222
+ $ this ->assertCount (0 , $ attachments );
223
+
224
+ $ this ->sent = [];
225
+ $ this ->composeEmail ()->attachData (false , 'test.png ' )->send ();
226
+ $ this ->artisan ('email:send ' );
227
+ $ attachments = reset ($ this ->sent )->getMessage ()->getChildren ();
228
+ $ this ->assertCount (0 , $ attachments );
229
+
230
+ $ this ->sent = [];
231
+ $ this ->composeEmail ()->attachData ('' , 'test.png ' )->send ();
232
+ $ this ->artisan ('email:send ' );
233
+ $ attachments = reset ($ this ->sent )->getMessage ()->getChildren ();
234
+ $ this ->assertCount (0 , $ attachments );
235
+ }
192
236
}
0 commit comments