diff --git a/test/MessageTest.php b/test/MessageTest.php index 6440705..ff1f931 100644 --- a/test/MessageTest.php +++ b/test/MessageTest.php @@ -401,5 +401,31 @@ public function testDecodeMultipartMimeMessageWithMessagePartAlternatives() "application/vnd.openxmlformats-officedocument.wordprocessingml.document;\r\n name=\"DockMcWordface.docx\"", $headers->get('Content-Type')->getFieldValue() ); + + $attachments = array_filter($parts, function ($part, $index) { + return str_starts_with( + (string) $part->getDisposition(), + "attachment" + ); + }, ARRAY_FILTER_USE_BOTH); + $this->assertCount(1, $attachments); + + $nonAttachments = array_filter($parts, function ($part, $index) { + return ! str_starts_with( + (string) $part->getDisposition(), + "attachment" + ); + }, ARRAY_FILTER_USE_BOTH); + $this->assertCount(1, $nonAttachments); + $this->assertCount(2, $nonAttachments[0]->getParts()); + + /** @var Part[] $noteParts */ + $noteParts = array_filter($nonAttachments[0]->getParts(), function ($part, $index) { + return str_starts_with( + (string) $part->getType(), + "text/plain" + ); + }, ARRAY_FILTER_USE_BOTH); + $this->assertSame("This is a test email with 1 attachment.", trim($noteParts[0]->getContent())); } }