@@ -246,6 +246,45 @@ public function testRunToolsEmailMessageClassString() {
246246 $ this ->Task ->run ($ data , 0 );
247247 }
248248
249+ /**
250+ * Test that attachments are properly handled when passed as an array
251+ *
252+ * @return void
253+ */
254+ public function testRunWithAttachments () {
255+ $ attachments = [
256+ 'file1.txt ' => [
257+ 'file ' => '/tmp/file1.txt ' ,
258+ 'mimetype ' => 'text/plain ' ,
259+ ],
260+ 'file2.pdf ' => '/tmp/file2.pdf ' ,
261+ ];
262+
263+ $ settings = [
264+ 265+ 266+ 'subject ' => 'Test with attachments ' ,
267+ 'attachments ' => $ attachments ,
268+ ];
269+
270+ $ data = [
271+ 'settings ' => $ settings ,
272+ 'content ' => 'Email with attachments ' ,
273+ ];
274+
275+ $ this ->Task ->run ($ data , 0 );
276+
277+ $ this ->assertInstanceOf (Mailer::class, $ this ->Task ->mailer );
278+
279+ $ mailerAttachments = $ this ->Task ->mailer ->getMessage ()->getAttachments ();
280+ $ this ->assertCount (2 , $ mailerAttachments );
281+ $ this ->assertArrayHasKey ('file1.txt ' , $ mailerAttachments );
282+ $ this ->assertArrayHasKey ('file2.pdf ' , $ mailerAttachments );
283+ $ this ->assertSame ('/tmp/file1.txt ' , $ mailerAttachments ['file1.txt ' ]['file ' ]);
284+ $ this ->assertSame ('text/plain ' , $ mailerAttachments ['file1.txt ' ]['mimetype ' ]);
285+ $ this ->assertSame ('/tmp/file2.pdf ' , $ mailerAttachments ['file2.pdf ' ]);
286+ }
287+
249288 /**
250289 * Helper method for skipping tests that need a non Postgres connection.
251290 *
0 commit comments