| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
namespace Tests\fixtures; |
| 14 |
|
| 15 |
use Webklex\PHPIMAP\Attachment; |
| 16 |
use Webklex\PHPIMAP\Support\AttachmentCollection; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
class MultipleHtmlPartsAndAttachmentsTest extends FixtureTestCase { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function testFixture() : void { |
| 31 |
$message = $this->getFixture("multiple_html_parts_and_attachments.eml"); |
| 32 |
|
| 33 |
self::assertEquals("multiple_html_parts_and_attachments", $message->subject); |
| 34 |
self::assertEquals("This is the first html part\r\n\r\n\r\n\r\nThis is the second html part\r\n\r\n\r\n\r\nThis is the last html part\r\nhttps://www.there.com", $message->getTextBody()); |
| 35 |
self::assertEquals("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=us-ascii\"></head><body style=\"overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;\">This is the <b>first</b> html <u>part</u><br><br></body></html>\n<html><body style=\"overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;\"><head><meta http-equiv=\"content-type\" content=\"text/html; charset=us-ascii\"></head><br><br>This is <strike>the</strike> second html <i>part</i><br><br></body></html>\n<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=us-ascii\"></head><body style=\"overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;\"><br><br><font size=\"2\"><i>This</i> is the last <b>html</b> part</font><div>https://www.there.com</div><div><br></div><br><br>\r\n<br></body></html>", $message->getHTMLBody()); |
| 36 |
|
| 37 |
self::assertEquals("2023-02-16 09:19:02", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s")); |
| 38 |
|
| 39 |
$from = $message->from->first(); |
| 40 |
self::assertEquals("FromName", $from->personal); |
| 41 |
self::assertEquals("from", $from->mailbox); |
| 42 |
self::assertEquals("there.com", $from->host); |
| 43 |
self::assertEquals("[email protected]", $from->mail); |
| 44 |
self::assertEquals("FromName <[email protected]>", $from->full); |
| 45 |
|
| 46 |
self::assertEquals("[email protected]", $message->to->first()); |
| 47 |
|
| 48 |
$attachments = $message->attachments(); |
| 49 |
self::assertInstanceOf(AttachmentCollection::class, $attachments); |
| 50 |
self::assertCount(2, $attachments); |
| 51 |
|
| 52 |
$attachment = $attachments[0]; |
| 53 |
self::assertInstanceOf(Attachment::class, $attachment); |
| 54 |
self::assertEquals("attachment1.pdf", $attachment->name); |
| 55 |
self::assertEquals('pdf', $attachment->getExtension()); |
| 56 |
self::assertEquals('text', $attachment->type); |
| 57 |
self::assertEquals("application/pdf", $attachment->content_type); |
| 58 |
self::assertEquals("c162adf19e0f67e26ef0b7f791b33a60b2c23b175560a505dc7f9ec490206e49", hash("sha256", $attachment->content)); |
| 59 |
self::assertEquals(4814, $attachment->size); |
| 60 |
self::assertEquals(2, $attachment->part_number); |
| 61 |
self::assertEquals("inline", $attachment->disposition); |
| 62 |
self::assertNotEmpty($attachment->id); |
| 63 |
|
| 64 |
$attachment = $attachments[1]; |
| 65 |
self::assertInstanceOf(Attachment::class, $attachment); |
| 66 |
self::assertEquals("attachment2.pdf", $attachment->name); |
| 67 |
self::assertEquals('pdf', $attachment->getExtension()); |
| 68 |
self::assertEquals('text', $attachment->type); |
| 69 |
self::assertEquals("application/pdf", $attachment->content_type); |
| 70 |
self::assertEquals("a337b37e9d3edb172a249639919f0eee3d344db352046d15f8f9887e55855a25", hash("sha256", $attachment->content)); |
| 71 |
self::assertEquals(5090, $attachment->size); |
| 72 |
self::assertEquals(4, $attachment->part_number); |
| 73 |
self::assertEquals("inline", $attachment->disposition); |
| 74 |
self::assertNotEmpty($attachment->id); |
| 75 |
} |
| 76 |
} |