mirror of
https://github.com/itflow-org/itflow
synced 2026-03-17 03:04:50 +00:00
Migrated away from PHP Mail Parser to the new WebKlex PHP IMAP Mail Parser this will open the way to support OAUTH2 for Mail servers such as Microsoft 365 and Google Workspaces
This commit is contained in:
52
plugins/php-imap/tests/fixtures/AttachmentEncodedFilenameTest.php
vendored
Normal file
52
plugins/php-imap/tests/fixtures/AttachmentEncodedFilenameTest.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*
|
||||
* File: AttachmentEncodedFilenameTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class AttachmentEncodedFilenameTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class AttachmentEncodedFilenameTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture attachment_encoded_filename.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("attachment_encoded_filename.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertEquals("multipart/mixed", $message->content_type->last());
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertCount(1, $message->attachments());
|
||||
|
||||
$attachment = $message->attachments()->first();
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("Prostřeno_2014_poslední volné termíny.xls", $attachment->filename);
|
||||
self::assertEquals("Prostřeno_2014_poslední volné termíny.xls", $attachment->name);
|
||||
self::assertEquals('xls', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/vnd.ms-excel", $attachment->content_type);
|
||||
self::assertEquals("a0ef7cfbc05b73dbcb298fe0bc224b41900cdaf60f9904e3fea5ba6c7670013c", hash("sha256", $attachment->content));
|
||||
self::assertEquals(146, $attachment->size);
|
||||
self::assertEquals(0, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
79
plugins/php-imap/tests/fixtures/AttachmentLongFilenameTest.php
vendored
Normal file
79
plugins/php-imap/tests/fixtures/AttachmentLongFilenameTest.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
* File: AttachmentLongFilenameTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class AttachmentLongFilenameTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class AttachmentLongFilenameTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture attachment_long_filename.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("attachment_long_filename.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertEquals("multipart/mixed", $message->content_type->last());
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
$attachments = $message->attachments();
|
||||
self::assertCount(3, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("Buchungsbestätigung- Rechnung-Geschäftsbedingungen-Nr.B123-45 - XXXX xxxxxxxxxxxxxxxxx XxxX, Lüdxxxxxxxx - VM Klaus XXXXXX - xxxxxxxx.pdf", $attachment->name);
|
||||
self::assertEquals("Buchungsbestätigung- Rechnung-Geschäftsbedingungen-Nr.B123-45 - XXXXX xxxxxxxxxxxxxxxxx XxxX, Lüxxxxxxxxxx - VM Klaus XXXXXX - xxxxxxxx.pdf", $attachment->filename);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('pdf', $attachment->getExtension());
|
||||
self::assertEquals("text/plain", $attachment->content_type);
|
||||
self::assertEquals("ca51ce1fb15acc6d69b8a5700256172fcc507e02073e6f19592e341bd6508ab8", hash("sha256", $attachment->content));
|
||||
self::assertEquals(4, $attachment->size);
|
||||
self::assertEquals(0, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('01_A€àäąбيد@Z-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz.txt', $attachment->name);
|
||||
self::assertEquals("f7b5181985862431bfc443d26e3af2371e20a0afd676eeb9b9595a26d42e0b73", hash("sha256", $attachment->filename));
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('txt', $attachment->getExtension());
|
||||
self::assertEquals("text/plain", $attachment->content_type);
|
||||
self::assertEquals("ca51ce1fb15acc6d69b8a5700256172fcc507e02073e6f19592e341bd6508ab8", hash("sha256", $attachment->content));
|
||||
self::assertEquals(4, $attachment->size);
|
||||
self::assertEquals(1, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[2];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('02_A€àäąбيد@Z-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz.txt', $attachment->name);
|
||||
self::assertEquals('02_A€àäąбيد@Z-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz-0123456789-qwertyuiopasdfghjklzxcvbnmopqrstuvz.txt', $attachment->filename);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("text/plain", $attachment->content_type);
|
||||
self::assertEquals('txt', $attachment->getExtension());
|
||||
self::assertEquals("ca51ce1fb15acc6d69b8a5700256172fcc507e02073e6f19592e341bd6508ab8", hash("sha256", $attachment->content));
|
||||
self::assertEquals(4, $attachment->size);
|
||||
self::assertEquals(2, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
55
plugins/php-imap/tests/fixtures/AttachmentNoDispositionTest.php
vendored
Normal file
55
plugins/php-imap/tests/fixtures/AttachmentNoDispositionTest.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* File: AttachmentNoDispositionTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class AttachmentNoDispositionTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class AttachmentNoDispositionTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture attachment_no_disposition.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("attachment_no_disposition.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertEquals("multipart/mixed", $message->content_type->last());
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertCount(1, $message->attachments());
|
||||
|
||||
$attachment = $message->attachments()->first();
|
||||
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('26ed3dd2', $attachment->filename);
|
||||
self::assertEquals('26ed3dd2', $attachment->id);
|
||||
self::assertEquals("Prostřeno_2014_poslední volné termíny.xls", $attachment->name);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('xls', $attachment->getExtension());
|
||||
self::assertEquals("application/vnd.ms-excel", $attachment->content_type);
|
||||
self::assertEquals("a0ef7cfbc05b73dbcb298fe0bc224b41900cdaf60f9904e3fea5ba6c7670013c", hash("sha256", $attachment->content));
|
||||
self::assertEquals(146, $attachment->size);
|
||||
self::assertEquals(0, $attachment->part_number);
|
||||
self::assertNull($attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
self::assertEmpty($attachment->content_id);
|
||||
}
|
||||
}
|
||||
43
plugins/php-imap/tests/fixtures/BccTest.php
vendored
Normal file
43
plugins/php-imap/tests/fixtures/BccTest.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* File: BccTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class BccTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class BccTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture bcc.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("bcc.eml");
|
||||
|
||||
self::assertEquals("test", $message->subject);
|
||||
self::assertEquals("<return-path@here.com>", $message->return_path);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("text/plain", $message->content_type);
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from);
|
||||
self::assertEquals("to@here.com", $message->to);
|
||||
self::assertEquals("A_€@{è_Z <bcc@here.com>", $message->bcc);
|
||||
self::assertEquals("sender@here.com", $message->sender);
|
||||
self::assertEquals("reply-to@here.com", $message->reply_to);
|
||||
}
|
||||
}
|
||||
55
plugins/php-imap/tests/fixtures/BooleanDecodedContentTest.php
vendored
Normal file
55
plugins/php-imap/tests/fixtures/BooleanDecodedContentTest.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* File: BooleanDecodedContentTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class BooleanDecodedContentTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class BooleanDecodedContentTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture boolean_decoded_content.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("boolean_decoded_content.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->subject);
|
||||
self::assertEquals("Here is the problem mail\r\n \r\nBody text", $message->getTextBody());
|
||||
self::assertEquals("Here is the problem mail\r\n \r\nBody text", $message->getHTMLBody());
|
||||
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from);
|
||||
self::assertEquals("to@here.com", $message->to);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
self::assertCount(1, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("Example Domain.pdf", $attachment->name);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('pdf', $attachment->getExtension());
|
||||
self::assertEquals("application/pdf", $attachment->content_type);
|
||||
self::assertEquals("1c449aaab4f509012fa5eaa180fd017eb7724ccacabdffc1c6066d3756dcde5c", hash("sha256", $attachment->content));
|
||||
self::assertEquals(53, $attachment->size);
|
||||
self::assertEquals(3, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
115
plugins/php-imap/tests/fixtures/DateTemplateTest.php
vendored
Normal file
115
plugins/php-imap/tests/fixtures/DateTemplateTest.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/*
|
||||
* File: DateTemplateTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Exceptions\AuthFailedException;
|
||||
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
|
||||
use Webklex\PHPIMAP\Exceptions\ImapBadRequestException;
|
||||
use Webklex\PHPIMAP\Exceptions\ImapServerErrorException;
|
||||
use Webklex\PHPIMAP\Exceptions\InvalidMessageDateException;
|
||||
use Webklex\PHPIMAP\Exceptions\MaskNotFoundException;
|
||||
use Webklex\PHPIMAP\Exceptions\MessageContentFetchingException;
|
||||
use Webklex\PHPIMAP\Exceptions\ResponseException;
|
||||
use Webklex\PHPIMAP\Exceptions\RuntimeException;
|
||||
use Webklex\PHPIMAP\Message;
|
||||
use \ReflectionException;
|
||||
|
||||
|
||||
/**
|
||||
* Class DateTemplateTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class DateTemplateTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test if the date is parsed correctly
|
||||
* @var array|string[] $dates
|
||||
*/
|
||||
protected array $dates = [
|
||||
"Fri, 5 Apr 2019 12:10:49 +0200" => "2019-04-05 10:10:49",
|
||||
"04 Jan 2018 10:12:47 UT" => "2018-01-04 10:12:47",
|
||||
"22 Jun 18 03:56:36 PM -05:00 (GMT -05:00)" => "2018-06-22 20:56:36",
|
||||
"Sat, 31 Aug 2013 20:08:23 +0580" => "2013-08-31 14:38:23",
|
||||
"Fri, 1 Feb 2019 01:30:04 +0600 (+06)" => "2019-01-31 19:30:04",
|
||||
"Mon, 4 Feb 2019 04:03:49 -0300 (-03)" => "2019-02-04 07:03:49",
|
||||
"Sun, 6 Apr 2008 21:24:33 UT" => "2008-04-06 21:24:33",
|
||||
"Wed, 11 Sep 2019 15:23:06 +0600 (+06)" => "2019-09-11 09:23:06",
|
||||
"14 Sep 2019 00:10:08 UT +0200" => "2019-09-14 00:10:08",
|
||||
"Tue, 08 Nov 2022 18:47:20 +0000 14:03:33 +0000" => "2022-11-08 18:47:20",
|
||||
"Sat, 10, Dec 2022 09:35:19 +0100" => "2022-12-10 08:35:19",
|
||||
"Thur, 16 Mar 2023 15:33:07 +0400" => "2023-03-16 11:33:07",
|
||||
"fr., 25 nov. 2022 06:27:14 +0100/fr., 25 nov. 2022 06:27:14 +0100" => "2022-11-25 05:27:14",
|
||||
"Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)/Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)" => "2022-02-15 05:52:44",
|
||||
];
|
||||
|
||||
/**
|
||||
* Test the fixture date-template.eml
|
||||
*
|
||||
* @return void
|
||||
* @throws InvalidMessageDateException
|
||||
* @throws ReflectionException
|
||||
* @throws AuthFailedException
|
||||
* @throws ConnectionFailedException
|
||||
* @throws ImapBadRequestException
|
||||
* @throws ImapServerErrorException
|
||||
* @throws MaskNotFoundException
|
||||
* @throws MessageContentFetchingException
|
||||
* @throws ResponseException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
try {
|
||||
$message = $this->getFixture("date-template.eml");
|
||||
$this->fail("Expected InvalidMessageDateException");
|
||||
} catch (InvalidMessageDateException $e) {
|
||||
self::assertTrue(true);
|
||||
}
|
||||
|
||||
self::$manager->setConfig([
|
||||
"options" => [
|
||||
"fallback_date" => "2021-01-01 00:00:00",
|
||||
],
|
||||
]);
|
||||
$message = $this->getFixture("date-template.eml", self::$manager->getConfig());
|
||||
|
||||
self::assertEquals("test", $message->subject);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2021-01-01 00:00:00", $message->date->first()->timezone("UTC")->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", (string)$message->from);
|
||||
self::assertEquals("to@here.com", $message->to);
|
||||
|
||||
self::$manager->setConfig([
|
||||
"options" => [
|
||||
"fallback_date" => null,
|
||||
],
|
||||
]);
|
||||
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "date-template.eml"]);
|
||||
$blob = file_get_contents($filename);
|
||||
self::assertNotFalse($blob);
|
||||
|
||||
foreach ($this->dates as $date => $expected) {
|
||||
$message = Message::fromString(str_replace("%date_raw_header%", $date, $blob));
|
||||
self::assertEquals("test", $message->subject);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals($expected, $message->date->first()->timezone("UTC")->format("Y-m-d H:i:s"), "Date \"$date\" should be \"$expected\"");
|
||||
self::assertEquals("from@there.com", (string)$message->from);
|
||||
self::assertEquals("to@here.com", $message->to);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
plugins/php-imap/tests/fixtures/EmailAddressTest.php
vendored
Normal file
39
plugins/php-imap/tests/fixtures/EmailAddressTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* File: EmailAddressTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class EmailAddressTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class EmailAddressTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture email_address.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("email_address.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertEquals("123@example.com", $message->message_id);
|
||||
self::assertEquals("Hi\r\nHow are you?", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertFalse($message->date->first());
|
||||
self::assertEquals("no_host@UNKNOWN", (string)$message->from);
|
||||
self::assertEquals("", $message->to);
|
||||
self::assertEquals("This one: is \"right\" <ding@dong.com>, No-address@UNKNOWN", $message->cc);
|
||||
}
|
||||
}
|
||||
64
plugins/php-imap/tests/fixtures/EmbeddedEmailTest.php
vendored
Normal file
64
plugins/php-imap/tests/fixtures/EmbeddedEmailTest.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
* File: EmbeddedEmailTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class EmbeddedEmailTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class EmbeddedEmailTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture embedded_email.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("embedded_email.eml");
|
||||
|
||||
self::assertEquals("embedded message", $message->subject);
|
||||
self::assertEquals([
|
||||
'from webmail.my-office.cz (localhost [127.0.0.1]) by keira.cofis.cz ; Fri, 29 Jan 2016 14:25:40 +0100',
|
||||
'from webmail.my-office.cz (localhost [127.0.0.1]) by keira.cofis.cz'
|
||||
], $message->received->toArray());
|
||||
self::assertEquals("7e5798da5747415e5b82fdce042ab2a6@cerstor.cz", $message->message_id);
|
||||
self::assertEquals("demo@cerstor.cz", $message->return_path);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("Roundcube Webmail/1.0.0", $message->user_agent);
|
||||
self::assertEquals("email that contains embedded message", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertEquals("2016-01-29 13:25:40", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("demo@cerstor.cz", $message->from);
|
||||
self::assertEquals("demo@cerstor.cz", $message->x_sender);
|
||||
self::assertEquals("demo@cerstor.cz", $message->to);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
self::assertCount(1, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("demo.eml", $attachment->name);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('eml', $attachment->getExtension());
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("a1f965f10a9872e902a82dde039a237e863f522d238a1cb1968fe3396dbcac65", hash("sha256", $attachment->content));
|
||||
self::assertEquals(893, $attachment->size);
|
||||
self::assertEquals(1, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
75
plugins/php-imap/tests/fixtures/EmbeddedEmailWithoutContentDispositionEmbeddedTest.php
vendored
Normal file
75
plugins/php-imap/tests/fixtures/EmbeddedEmailWithoutContentDispositionEmbeddedTest.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
* File: EmbeddedEmailWithoutContentDispositionEmbeddedTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class EmbeddedEmailWithoutContentDispositionEmbeddedTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class EmbeddedEmailWithoutContentDispositionEmbeddedTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture embedded_email_without_content_disposition-embedded.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("embedded_email_without_content_disposition-embedded.eml");
|
||||
|
||||
self::assertEquals("embedded_message_subject", $message->subject);
|
||||
self::assertEquals([
|
||||
'from webmail.my-office.cz (localhost [127.0.0.1]) by keira.cofis.cz ; Fri, 29 Jan 2016 14:25:40 +0100',
|
||||
'from webmail.my-office.cz (localhost [127.0.0.1]) by keira.cofis.cz'
|
||||
], $message->received->toArray());
|
||||
self::assertEquals("AC39946EBF5C034B87BABD5343E96979012671D40E38@VM002.cerk.cc", $message->message_id);
|
||||
self::assertEquals("pl-PL, nl-NL", $message->accept_language);
|
||||
self::assertEquals("pl-PL", $message->content_language);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("some txt", $message->getTextBody());
|
||||
self::assertEquals("<html>\r\n <p>some txt</p>\r\n</html>", $message->getHTMLBody());
|
||||
|
||||
self::assertEquals("2019-04-05 10:10:49", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("demo@cerstor.cz", $message->from);
|
||||
self::assertEquals("demo@cerstor.cz", $message->to);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
self::assertCount(2, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("file1.xlsx", $attachment->name);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('xlsx', $attachment->getExtension());
|
||||
self::assertEquals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $attachment->content_type);
|
||||
self::assertEquals("87737d24c106b96e177f9564af6712e2c6d3e932c0632bfbab69c88b0bb934dc", hash("sha256", $attachment->content));
|
||||
self::assertEquals(40, $attachment->size);
|
||||
self::assertEquals(3, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("file2.xlsx", $attachment->name);
|
||||
self::assertEquals('xlsx', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $attachment->content_type);
|
||||
self::assertEquals("87737d24c106b96e177f9564af6712e2c6d3e932c0632bfbab69c88b0bb934dc", hash("sha256", $attachment->content));
|
||||
self::assertEquals(40, $attachment->size);
|
||||
self::assertEquals(4, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
98
plugins/php-imap/tests/fixtures/EmbeddedEmailWithoutContentDispositionTest.php
vendored
Normal file
98
plugins/php-imap/tests/fixtures/EmbeddedEmailWithoutContentDispositionTest.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
* File: EmbeddedEmailWithoutContentDispositionTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class EmbeddedEmailWithoutContentDispositionTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class EmbeddedEmailWithoutContentDispositionTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture embedded_email_without_content_disposition.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("embedded_email_without_content_disposition.eml");
|
||||
|
||||
self::assertEquals("Subject", $message->subject);
|
||||
self::assertEquals([
|
||||
'from webmail.my-office.cz (localhost [127.0.0.1]) by keira.cofis.cz ; Fri, 29 Jan 2016 14:25:40 +0100',
|
||||
'from webmail.my-office.cz (localhost [127.0.0.1]) by keira.cofis.cz'
|
||||
], $message->received->toArray());
|
||||
self::assertEquals("AC39946EBF5C034B87BABD5343E96979012671D9F7E4@VM002.cerk.cc", $message->message_id);
|
||||
self::assertEquals("pl-PL, nl-NL", $message->accept_language);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("TexT\r\n\r\n[cid:file.jpg]", $message->getTextBody());
|
||||
self::assertEquals("<html><p>TexT</p></html>", $message->getHTMLBody());
|
||||
|
||||
self::assertEquals("2019-04-05 11:48:50", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("demo@cerstor.cz", $message->from);
|
||||
self::assertEquals("demo@cerstor.cz", $message->to);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
self::assertCount(4, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("file.jpg", $attachment->name);
|
||||
self::assertEquals('jpg', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("image/jpeg", $attachment->content_type);
|
||||
self::assertEquals("6b7fa434f92a8b80aab02d9bf1a12e49ffcae424e4013a1c4f68b67e3d2bbcd0", hash("sha256", $attachment->content));
|
||||
self::assertEquals(96, $attachment->size);
|
||||
self::assertEquals(3, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('a1abc19a', $attachment->name);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('', $attachment->getExtension());
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("2476c8b91a93c6b2fe1bfff593cb55956c2fe8e7ca6de9ad2dc9d101efe7a867", hash("sha256", $attachment->content));
|
||||
self::assertEquals(2073, $attachment->size);
|
||||
self::assertEquals(5, $attachment->part_number);
|
||||
self::assertNull($attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[2];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("file3.xlsx", $attachment->name);
|
||||
self::assertEquals('xlsx', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $attachment->content_type);
|
||||
self::assertEquals("87737d24c106b96e177f9564af6712e2c6d3e932c0632bfbab69c88b0bb934dc", hash("sha256", $attachment->content));
|
||||
self::assertEquals(40, $attachment->size);
|
||||
self::assertEquals(6, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[3];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("file4.zip", $attachment->name);
|
||||
self::assertEquals('zip', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/x-zip-compressed", $attachment->content_type);
|
||||
self::assertEquals("87737d24c106b96e177f9564af6712e2c6d3e932c0632bfbab69c88b0bb934dc", hash("sha256", $attachment->content));
|
||||
self::assertEquals(40, $attachment->size);
|
||||
self::assertEquals(7, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
99
plugins/php-imap/tests/fixtures/ExampleBounceTest.php
vendored
Normal file
99
plugins/php-imap/tests/fixtures/ExampleBounceTest.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/*
|
||||
* File: ExampleBounceTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class ExampleBounceTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class ExampleBounceTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture example_bounce.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture(): void {
|
||||
$message = $this->getFixture("example_bounce.eml");
|
||||
|
||||
self::assertEquals("<>", $message->return_path);
|
||||
self::assertEquals([
|
||||
0 => 'from somewhere.your-server.de by somewhere.your-server.de with LMTP id 3TP8LrElAGSOaAAAmBr1xw (envelope-from <>); Thu, 02 Mar 2023 05:27:29 +0100',
|
||||
1 => 'from somewhere06.your-server.de ([1b21:2f8:e0a:50e4::2]) by somewhere.your-server.de with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) id 1pXaXR-0006xQ-BN for demo@foo.de; Thu, 02 Mar 2023 05:27:29 +0100',
|
||||
2 => 'from [192.168.0.10] (helo=sslproxy01.your-server.de) by somewhere06.your-server.de with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) id 1pXaXO-000LYP-9R for demo@foo.de; Thu, 02 Mar 2023 05:27:26 +0100',
|
||||
3 => 'from localhost ([127.0.0.1] helo=sslproxy01.your-server.de) by sslproxy01.your-server.de with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) id 1pXaXO-0008gy-7x for demo@foo.de; Thu, 02 Mar 2023 05:27:26 +0100',
|
||||
4 => 'from Debian-exim by sslproxy01.your-server.de with local (Exim 4.92) id 1pXaXO-0008gb-6g for demo@foo.de; Thu, 02 Mar 2023 05:27:26 +0100',
|
||||
5 => 'from somewhere.your-server.de by somewhere.your-server.de with LMTP id 3TP8LrElAGSOaAAAmBr1xw (envelope-from <>)',
|
||||
], $message->received->all());
|
||||
self::assertEquals("demo@foo.de", $message->envelope_to);
|
||||
self::assertEquals("Thu, 02 Mar 2023 05:27:29 +0100", $message->delivery_date);
|
||||
self::assertEquals([
|
||||
0 => 'somewhere.your-server.de; iprev=pass (somewhere06.your-server.de) smtp.remote-ip=1b21:2f8:e0a:50e4::2; spf=none smtp.mailfrom=<>; dmarc=skipped',
|
||||
1 => 'somewhere.your-server.de'
|
||||
], $message->authentication_results->all());
|
||||
self::assertEquals([
|
||||
0 => 'from somewhere.your-server.de by somewhere.your-server.de with LMTP id 3TP8LrElAGSOaAAAmBr1xw (envelope-from <>); Thu, 02 Mar 2023 05:27:29 +0100',
|
||||
1 => 'from somewhere06.your-server.de ([1b21:2f8:e0a:50e4::2]) by somewhere.your-server.de with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) id 1pXaXR-0006xQ-BN for demo@foo.de; Thu, 02 Mar 2023 05:27:29 +0100',
|
||||
2 => 'from [192.168.0.10] (helo=sslproxy01.your-server.de) by somewhere06.your-server.de with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) id 1pXaXO-000LYP-9R for demo@foo.de; Thu, 02 Mar 2023 05:27:26 +0100',
|
||||
3 => 'from localhost ([127.0.0.1] helo=sslproxy01.your-server.de) by sslproxy01.your-server.de with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) id 1pXaXO-0008gy-7x for demo@foo.de; Thu, 02 Mar 2023 05:27:26 +0100',
|
||||
4 => 'from Debian-exim by sslproxy01.your-server.de with local (Exim 4.92) id 1pXaXO-0008gb-6g for demo@foo.de; Thu, 02 Mar 2023 05:27:26 +0100',
|
||||
5 => 'from somewhere.your-server.de by somewhere.your-server.de with LMTP id 3TP8LrElAGSOaAAAmBr1xw (envelope-from <>)',
|
||||
], $message->received->all());
|
||||
self::assertEquals("ding@ding.de", $message->x_failed_recipients);
|
||||
self::assertEquals("auto-replied", $message->auto_submitted);
|
||||
self::assertEquals("Mail Delivery System <Mailer-Daemon@sslproxy01.your-server.de>", $message->from);
|
||||
self::assertEquals("demo@foo.de", $message->to);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("Mail delivery failed", $message->subject);
|
||||
self::assertEquals("E1pXaXO-0008gb-6g@sslproxy01.your-server.de", $message->message_id);
|
||||
self::assertEquals("2023-03-02 04:27:26", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("Clear (ClamAV 0.103.8/26827/Wed Mar 1 09:28:49 2023)", $message->x_virus_scanned);
|
||||
self::assertEquals("0.0 (/)", $message->x_spam_score);
|
||||
self::assertEquals("bar-demo@foo.de", $message->delivered_to);
|
||||
self::assertEquals("multipart/report", $message->content_type->last());
|
||||
self::assertEquals("5d4847c21c8891e73d62c8246f260a46496958041a499f33ecd47444fdaa591b", hash("sha256", $message->getTextBody()));
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
$attachments = $message->attachments();
|
||||
self::assertCount(2, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('c541a506', $attachment->filename);
|
||||
self::assertEquals("c541a506", $attachment->name);
|
||||
self::assertEquals('', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("message/delivery-status", $attachment->content_type);
|
||||
self::assertEquals("85ac09d1d74b2d85853084dc22abcad205a6bfde62d6056e3a933ffe7e82e45c", hash("sha256", $attachment->content));
|
||||
self::assertEquals(267, $attachment->size);
|
||||
self::assertEquals(1, $attachment->part_number);
|
||||
self::assertNull($attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('da786518', $attachment->filename);
|
||||
self::assertEquals("da786518", $attachment->name);
|
||||
self::assertEquals('', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("7525331f5fab23ea77f595b995336aca7b8dad12db00ada14abebe7fe5b96e10", hash("sha256", $attachment->content));
|
||||
self::assertEquals(776, $attachment->size);
|
||||
self::assertEquals(2, $attachment->part_number);
|
||||
self::assertNull($attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
94
plugins/php-imap/tests/fixtures/FixtureTestCase.php
vendored
Normal file
94
plugins/php-imap/tests/fixtures/FixtureTestCase.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*
|
||||
* File: FixtureTestCase.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Webklex\PHPIMAP\ClientManager;
|
||||
use Webklex\PHPIMAP\Config;
|
||||
use Webklex\PHPIMAP\Exceptions\AuthFailedException;
|
||||
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
|
||||
use Webklex\PHPIMAP\Exceptions\ImapBadRequestException;
|
||||
use Webklex\PHPIMAP\Exceptions\ImapServerErrorException;
|
||||
use Webklex\PHPIMAP\Exceptions\InvalidMessageDateException;
|
||||
use Webklex\PHPIMAP\Exceptions\MaskNotFoundException;
|
||||
use Webklex\PHPIMAP\Exceptions\MessageContentFetchingException;
|
||||
use Webklex\PHPIMAP\Exceptions\ResponseException;
|
||||
use Webklex\PHPIMAP\Exceptions\RuntimeException;
|
||||
use Webklex\PHPIMAP\Message;
|
||||
use \ReflectionException;
|
||||
|
||||
/**
|
||||
* Class FixtureTestCase
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
abstract class FixtureTestCase extends TestCase {
|
||||
|
||||
/**
|
||||
* Client manager
|
||||
* @var ClientManager $manager
|
||||
*/
|
||||
protected static ClientManager $manager;
|
||||
|
||||
/**
|
||||
* FixtureTestCase constructor.
|
||||
* @param string|null $name
|
||||
* @param array $data
|
||||
* @param $dataName
|
||||
*/
|
||||
final public function __construct(?string $name = null, array $data = [], $dataName = '') {
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
self::$manager = new ClientManager([
|
||||
'options' => [
|
||||
"debug" => $_ENV["LIVE_MAILBOX_DEBUG"] ?? false,
|
||||
],
|
||||
'accounts' => [
|
||||
'default' => [
|
||||
'host' => getenv("LIVE_MAILBOX_HOST"),
|
||||
'port' => getenv("LIVE_MAILBOX_PORT"),
|
||||
'encryption' => getenv("LIVE_MAILBOX_ENCRYPTION"),
|
||||
'validate_cert' => getenv("LIVE_MAILBOX_VALIDATE_CERT"),
|
||||
'username' => getenv("LIVE_MAILBOX_USERNAME"),
|
||||
'password' => getenv("LIVE_MAILBOX_PASSWORD"),
|
||||
'protocol' => 'imap', //might also use imap, [pop3 or nntp (untested)]
|
||||
],
|
||||
],
|
||||
]);
|
||||
return self::$manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a fixture message
|
||||
* @param string $template
|
||||
*
|
||||
* @return Message
|
||||
* @throws ReflectionException
|
||||
* @throws AuthFailedException
|
||||
* @throws ConnectionFailedException
|
||||
* @throws ImapBadRequestException
|
||||
* @throws ImapServerErrorException
|
||||
* @throws InvalidMessageDateException
|
||||
* @throws MaskNotFoundException
|
||||
* @throws MessageContentFetchingException
|
||||
* @throws ResponseException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
final public function getFixture(string $template, Config $config = null) : Message {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", $template]);
|
||||
$message = Message::fromFile($filename, $config);
|
||||
self::assertInstanceOf(Message::class, $message);
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
55
plugins/php-imap/tests/fixtures/FourNestedEmailsTest.php
vendored
Normal file
55
plugins/php-imap/tests/fixtures/FourNestedEmailsTest.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* File: FourNestedEmailsTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class FourNestedEmailsTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class FourNestedEmailsTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture four_nested_emails.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("four_nested_emails.eml");
|
||||
|
||||
self::assertEquals("3-third-subject", $message->subject);
|
||||
self::assertEquals("3-third-content", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertFalse($message->date->first());
|
||||
self::assertEquals("test@example.com", $message->from->first()->mail);
|
||||
self::assertEquals("test@example.com", $message->to->first()->mail);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
self::assertCount(1, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("2-second-email.eml", $attachment->name);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('eml', $attachment->getExtension());
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("85012e6a26d064a0288ee62618b3192687385adb4a4e27e48a28f738a325ca46", hash("sha256", $attachment->content));
|
||||
self::assertEquals(1376, $attachment->size);
|
||||
self::assertEquals(2, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/GbkCharsetTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/GbkCharsetTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: GbkCharsetTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class GbkCharsetTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class GbkCharsetTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture gbk_charset.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("gbk_charset.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->subject);
|
||||
self::assertEquals("Hi", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/HtmlOnlyTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/HtmlOnlyTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: HtmlOnlyTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class HtmlOnlyTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class HtmlOnlyTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture html_only.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("html_only.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->subject);
|
||||
self::assertEquals("<html><body>Hi</body></html>", $message->getHTMLBody());
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/ImapMimeHeaderDecodeReturnsFalseTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/ImapMimeHeaderDecodeReturnsFalseTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: ImapMimeHeaderDecodeReturnsFalseTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class ImapMimeHeaderDecodeReturnsFalseTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class ImapMimeHeaderDecodeReturnsFalseTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture imap_mime_header_decode_returns_false.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("imap_mime_header_decode_returns_false.eml");
|
||||
|
||||
self::assertEquals("=?UTF-8?B?nnDusSNdG92w6Fuw61fMjAxOF8wMy0xMzMyNTMzMTkzLnBkZg==?=", $message->subject->first());
|
||||
self::assertEquals("Hi", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
62
plugins/php-imap/tests/fixtures/InlineAttachmentTest.php
vendored
Normal file
62
plugins/php-imap/tests/fixtures/InlineAttachmentTest.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
* File: InlineAttachmentTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
use Webklex\PHPIMAP\Support\AttachmentCollection;
|
||||
|
||||
/**
|
||||
* Class InlineAttachmentTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class InlineAttachmentTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture inline_attachment.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("inline_attachment.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertEquals('<img style="height: auto;" src="cid:ii_15f0aad691bb745f" border="0"/>', $message->getHTMLBody());
|
||||
|
||||
self::assertFalse($message->date->first());
|
||||
self::assertFalse($message->from->first());
|
||||
self::assertFalse($message->to->first());
|
||||
|
||||
|
||||
$attachments = $message->attachments();
|
||||
self::assertInstanceOf(AttachmentCollection::class, $attachments);
|
||||
self::assertCount(1, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals('d2913999', $attachment->name);
|
||||
self::assertEquals('d2913999', $attachment->filename);
|
||||
self::assertEquals('ii_15f0aad691bb745f', $attachment->id);
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals('', $attachment->getExtension());
|
||||
self::assertEquals("image/png", $attachment->content_type);
|
||||
self::assertEquals("6568c9e9c35a7fa06f236e89f704d8c9b47183a24f2c978dba6c92e2747e3a13", hash("sha256", $attachment->content));
|
||||
self::assertEquals(1486, $attachment->size);
|
||||
self::assertEquals(1, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertEquals("<ii_15f0aad691bb745f>", $attachment->content_id);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
46
plugins/php-imap/tests/fixtures/KsC56011987HeadersTest.php
vendored
Normal file
46
plugins/php-imap/tests/fixtures/KsC56011987HeadersTest.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* File: KsC56011987HeadersTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class KsC56011987HeadersTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class KsC56011987HeadersTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture ks_c_5601-1987_headers.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("ks_c_5601-1987_headers.eml");
|
||||
|
||||
self::assertEquals("RE: 회원님께 Ersi님이 메시지를 보냈습니다.", $message->subject);
|
||||
self::assertEquals("=?ks_c_5601-1987?B?yLi/+LTUsrIgRXJzabTUwMwguN69w8H2uKYgurizwr3AtM+02S4=?=", $message->thread_topic);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertEquals("Content", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
|
||||
|
||||
$from = $message->from->first();
|
||||
self::assertEquals("김 현진", $from->personal);
|
||||
self::assertEquals("from", $from->mailbox);
|
||||
self::assertEquals("there.com", $from->host);
|
||||
self::assertEquals("from@there.com", $from->mail);
|
||||
self::assertEquals("김 현진 <from@there.com>", $from->full);
|
||||
}
|
||||
}
|
||||
63
plugins/php-imap/tests/fixtures/MailThatIsAttachmentTest.php
vendored
Normal file
63
plugins/php-imap/tests/fixtures/MailThatIsAttachmentTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MailThatIsAttachmentTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class MailThatIsAttachmentTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MailThatIsAttachmentTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture mail_that_is_attachment.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("mail_that_is_attachment.eml");
|
||||
|
||||
self::assertEquals("Report domain: yyy.cz Submitter: google.com Report-ID: 2244696771454641389", $message->subject);
|
||||
self::assertEquals("2244696771454641389@google.com", $message->message_id);
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertEquals("2015-02-15 10:21:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("xxx@yyy.cz", $message->to->first()->mail);
|
||||
self::assertEquals("xxx@yyy.cz", $message->sender->first()->mail);
|
||||
|
||||
$from = $message->from->first();
|
||||
self::assertEquals("noreply-dmarc-support via xxx", $from->personal);
|
||||
self::assertEquals("xxx", $from->mailbox);
|
||||
self::assertEquals("yyy.cz", $from->host);
|
||||
self::assertEquals("xxx@yyy.cz", $from->mail);
|
||||
self::assertEquals("noreply-dmarc-support via xxx <xxx@yyy.cz>", $from->full);
|
||||
|
||||
self::assertCount(1, $message->attachments());
|
||||
|
||||
$attachment = $message->attachments()->first();
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("google.com!yyy.cz!1423872000!1423958399.zip", $attachment->name);
|
||||
self::assertEquals('zip', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/zip", $attachment->content_type);
|
||||
self::assertEquals("c0d4f47b6fde124cea7460c3e509440d1a062705f550b0502b8ba0cbf621c97a", hash("sha256", $attachment->content));
|
||||
self::assertEquals(1062, $attachment->size);
|
||||
self::assertEquals(0, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/MissingDateTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/MissingDateTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MissingDateTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class MissingDateTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MissingDateTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture missing_date.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("missing_date.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->getSubject());
|
||||
self::assertEquals("Hi", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertFalse($message->date->first());
|
||||
self::assertEquals("from@here.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/MissingFromTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/MissingFromTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MissingFromTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class MissingFromTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MissingFromTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture missing_from.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("missing_from.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->getSubject());
|
||||
self::assertEquals("Hi", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertFalse($message->from->first());
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
61
plugins/php-imap/tests/fixtures/MixedFilenameTest.php
vendored
Normal file
61
plugins/php-imap/tests/fixtures/MixedFilenameTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MixedFilenameTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class MixedFilenameTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MixedFilenameTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture mixed_filename.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("mixed_filename.eml");
|
||||
|
||||
self::assertEquals("Свежий прайс-лист", $message->subject);
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertEquals("2018-02-02 19:23:06", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
|
||||
$from = $message->from->first();
|
||||
self::assertEquals("Прайсы || ПартКом", $from->personal);
|
||||
self::assertEquals("support", $from->mailbox);
|
||||
self::assertEquals("part-kom.ru", $from->host);
|
||||
self::assertEquals("support@part-kom.ru", $from->mail);
|
||||
self::assertEquals("Прайсы || ПартКом <support@part-kom.ru>", $from->full);
|
||||
|
||||
self::assertEquals("foo@bar.com", $message->to->first());
|
||||
|
||||
self::assertCount(1, $message->attachments());
|
||||
|
||||
$attachment = $message->attachments()->first();
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("Price4VladDaKar.xlsx", $attachment->name);
|
||||
self::assertEquals('xlsx', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/octet-stream", $attachment->content_type);
|
||||
self::assertEquals("b832983842b0ad65db69e4c7096444c540a2393e2d43f70c2c9b8b9fceeedbb1", hash('sha256', $attachment->content));
|
||||
self::assertEquals(94, $attachment->size);
|
||||
self::assertEquals(2, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
63
plugins/php-imap/tests/fixtures/MultipartWithoutBodyTest.php
vendored
Normal file
63
plugins/php-imap/tests/fixtures/MultipartWithoutBodyTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MultipartWithoutBodyTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class MultipartWithoutBodyTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MultipartWithoutBodyTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture multipart_without_body.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("multipart_without_body.eml");
|
||||
|
||||
self::assertEquals("This mail will not contain a body", $message->subject);
|
||||
self::assertEquals("This mail will not contain a body", $message->getTextBody());
|
||||
self::assertEquals("d76dfb1ff3231e3efe1675c971ce73f722b906cc049d328db0d255f8d3f65568", hash("sha256", $message->getHTMLBody()));
|
||||
self::assertEquals("2023-03-11 08:24:31", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("Foo Bülow Bar <from@example.com>", $message->from);
|
||||
self::assertEquals("some one <someone@somewhere.com>", $message->to);
|
||||
self::assertEquals([
|
||||
0 => 'from AS8PR02MB6805.eurprd02.prod.outlook.com (2603:10a6:20b:252::8) by PA4PR02MB7071.eurprd02.prod.outlook.com with HTTPS; Sat, 11 Mar 2023 08:24:33 +0000',
|
||||
1 => 'from omef0ahNgeoJu.eurprd02.prod.outlook.com (2603:10a6:10:33c::12) by AS8PR02MB6805.eurprd02.prod.outlook.com (2603:10a6:20b:252::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Sat, 11 Mar 2023 08:24:31 +0000',
|
||||
2 => 'from omef0ahNgeoJu.eurprd02.prod.outlook.com ([fe80::38c0:9c40:7fc6:93a7]) by omef0ahNgeoJu.eurprd02.prod.outlook.com ([fe80::38c0:9c40:7fc6:93a7%7]) with mapi id 15.20.6178.019; Sat, 11 Mar 2023 08:24:31 +0000',
|
||||
3 => 'from AS8PR02MB6805.eurprd02.prod.outlook.com (2603:10a6:20b:252::8) by PA4PR02MB7071.eurprd02.prod.outlook.com with HTTPS',
|
||||
], $message->received->all());
|
||||
self::assertEquals("This mail will not contain a body", $message->thread_topic);
|
||||
self::assertEquals("AdlT8uVmpHPvImbCRM6E9LODIvAcQA==", $message->thread_index);
|
||||
self::assertEquals("omef0ahNgeoJuEB51C568ED2227A2DAABB5BB9@omef0ahNgeoJu.eurprd02.prod.outlook.com", $message->message_id);
|
||||
self::assertEquals("da-DK, en-US", $message->accept_language);
|
||||
self::assertEquals("en-US", $message->content_language);
|
||||
self::assertEquals("Internal", $message->x_ms_exchange_organization_authAs);
|
||||
self::assertEquals("04", $message->x_ms_exchange_organization_authMechanism);
|
||||
self::assertEquals("omef0ahNgeoJu.eurprd02.prod.outlook.com", $message->x_ms_exchange_organization_authSource);
|
||||
self::assertEquals("", $message->x_ms_Has_Attach);
|
||||
self::assertEquals("aa546a02-2b7a-4fb1-7fd4-08db220a09f1", $message->x_ms_exchange_organization_Network_Message_Id);
|
||||
self::assertEquals("-1", $message->x_ms_exchange_organization_SCL);
|
||||
self::assertEquals("", $message->x_ms_TNEF_Correlator);
|
||||
self::assertEquals("0", $message->x_ms_exchange_organization_RecordReviewCfmType);
|
||||
self::assertEquals("Email", $message->x_ms_publictraffictype);
|
||||
self::assertEquals("ucf:0;jmr:0;auth:0;dest:I;ENG:(910001)(944506478)(944626604)(920097)(425001)(930097);", $message->X_Microsoft_Antispam_Mailbox_Delivery->first());
|
||||
self::assertEquals("0712b5fe22cf6e75fa220501c1a6715a61098983df9e69bad4000c07531c1295", hash("sha256", $message->X_Microsoft_Antispam_Message_Info));
|
||||
self::assertEquals("multipart/alternative", $message->Content_Type->last());
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
|
||||
self::assertCount(0, $message->getAttachments());
|
||||
}
|
||||
}
|
||||
76
plugins/php-imap/tests/fixtures/MultipleHtmlPartsAndAttachmentsTest.php
vendored
Normal file
76
plugins/php-imap/tests/fixtures/MultipleHtmlPartsAndAttachmentsTest.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MultipleHtmlPartsAndAttachmentsTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
use Webklex\PHPIMAP\Support\AttachmentCollection;
|
||||
|
||||
/**
|
||||
* Class MultipleHtmlPartsAndAttachmentsTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MultipleHtmlPartsAndAttachmentsTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture multiple_html_parts_and_attachments.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("multiple_html_parts_and_attachments.eml");
|
||||
|
||||
self::assertEquals("multiple_html_parts_and_attachments", $message->subject);
|
||||
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());
|
||||
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());
|
||||
|
||||
self::assertEquals("2023-02-16 09:19:02", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
|
||||
$from = $message->from->first();
|
||||
self::assertEquals("FromName", $from->personal);
|
||||
self::assertEquals("from", $from->mailbox);
|
||||
self::assertEquals("there.com", $from->host);
|
||||
self::assertEquals("from@there.com", $from->mail);
|
||||
self::assertEquals("FromName <from@there.com>", $from->full);
|
||||
|
||||
self::assertEquals("to@there.com", $message->to->first());
|
||||
|
||||
$attachments = $message->attachments();
|
||||
self::assertInstanceOf(AttachmentCollection::class, $attachments);
|
||||
self::assertCount(2, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("attachment1.pdf", $attachment->name);
|
||||
self::assertEquals('pdf', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/pdf", $attachment->content_type);
|
||||
self::assertEquals("c162adf19e0f67e26ef0b7f791b33a60b2c23b175560a505dc7f9ec490206e49", hash("sha256", $attachment->content));
|
||||
self::assertEquals(4814, $attachment->size);
|
||||
self::assertEquals(4, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("attachment2.pdf", $attachment->name);
|
||||
self::assertEquals('pdf', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/pdf", $attachment->content_type);
|
||||
self::assertEquals("a337b37e9d3edb172a249639919f0eee3d344db352046d15f8f9887e55855a25", hash("sha256", $attachment->content));
|
||||
self::assertEquals(5090, $attachment->size);
|
||||
self::assertEquals(6, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
69
plugins/php-imap/tests/fixtures/MultipleNestedAttachmentsTest.php
vendored
Normal file
69
plugins/php-imap/tests/fixtures/MultipleNestedAttachmentsTest.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
* File: MultipleNestedAttachmentsTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
use Webklex\PHPIMAP\Support\AttachmentCollection;
|
||||
|
||||
/**
|
||||
* Class MultipleNestedAttachmentsTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class MultipleNestedAttachmentsTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture multiple_nested_attachments.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("multiple_nested_attachments.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertEquals("------------------------------------------------------------------------", $message->getTextBody());
|
||||
self::assertEquals("<html>\r\n <head>\r\n\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n </head>\r\n <body text=\"#000000\" bgcolor=\"#FFFFFF\">\r\n <p><br>\r\n </p>\r\n <div class=\"moz-signature\">\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n <title></title>\r\n  <img src=\"cid:part1.8B953FBA.0E5A242C@xyz.xyz\" alt=\"\">\r\n <hr>\r\n <table width=\"20\" cellspacing=\"2\" cellpadding=\"2\" height=\"31\">\r\n <tbody>\r\n <tr>\r\n <td><br>\r\n </td>\r\n <td valign=\"middle\"><br>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </div>\r\n </body>\r\n</html>", $message->getHTMLBody());
|
||||
|
||||
self::assertEquals("2018-01-15 09:54:09", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertFalse($message->from->first());
|
||||
self::assertFalse($message->to->first());
|
||||
|
||||
$attachments = $message->attachments();
|
||||
self::assertInstanceOf(AttachmentCollection::class, $attachments);
|
||||
self::assertCount(2, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("mleokdgdlgkkecep.png", $attachment->name);
|
||||
self::assertEquals('png', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("image/png", $attachment->content_type);
|
||||
self::assertEquals("e0e99b0bd6d5ea3ced99add53cc98b6f8eea6eae8ddd773fd06f3489289385fb", hash("sha256", $attachment->content));
|
||||
self::assertEquals(114, $attachment->size);
|
||||
self::assertEquals(5, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("FF4D00-1.png", $attachment->name);
|
||||
self::assertEquals('png', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("image/png", $attachment->content_type);
|
||||
self::assertEquals("e0e99b0bd6d5ea3ced99add53cc98b6f8eea6eae8ddd773fd06f3489289385fb", hash("sha256", $attachment->content));
|
||||
self::assertEquals(114, $attachment->size);
|
||||
self::assertEquals(8, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
69
plugins/php-imap/tests/fixtures/NestesEmbeddedWithAttachmentTest.php
vendored
Normal file
69
plugins/php-imap/tests/fixtures/NestesEmbeddedWithAttachmentTest.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
* File: NestesEmbeddedWithAttachmentTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
use Webklex\PHPIMAP\Support\AttachmentCollection;
|
||||
|
||||
/**
|
||||
* Class NestesEmbeddedWithAttachmentTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class NestesEmbeddedWithAttachmentTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture nestes_embedded_with_attachment.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("nestes_embedded_with_attachment.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->subject);
|
||||
self::assertEquals("Dear Sarah", $message->getTextBody());
|
||||
self::assertEquals("<HTML><HEAD></HEAD>\r\n<BODY dir=ltr>\r\n<DIV>Dear Sarah,</DIV>\r\n</BODY></HTML>", $message->getHTMLBody());
|
||||
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
|
||||
$attachments = $message->attachments();
|
||||
self::assertInstanceOf(AttachmentCollection::class, $attachments);
|
||||
self::assertCount(2, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("first.eml", $attachment->name);
|
||||
self::assertEquals('eml', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("From: from@there.com\r\nTo: to@here.com\r\nSubject: FIRST\r\nDate: Sat, 28 Apr 2018 14:37:16 -0400\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed;\r\n boundary=\"----=_NextPart_000_222_000\"\r\n\r\nThis is a multi-part message in MIME format.\r\n\r\n------=_NextPart_000_222_000\r\nContent-Type: multipart/alternative;\r\n boundary=\"----=_NextPart_000_222_111\"\r\n\r\n\r\n------=_NextPart_000_222_111\r\nContent-Type: text/plain;\r\n charset=\"UTF-8\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nPlease respond directly to this email to update your RMA\r\n\r\n\r\n2018-04-17T11:04:03-04:00\r\n------=_NextPart_000_222_111\r\nContent-Type: text/html;\r\n charset=\"UTF-8\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n<HTML><HEAD></HEAD>\r\n<BODY dir=3Dltr>\r\n<DIV>Please respond directly to this =\r\nemail to=20\r\nupdate your RMA</DIV></BODY></HTML>\r\n\r\n------=_NextPart_000_222_111--\r\n\r\n------=_NextPart_000_222_000\r\nContent-Type: image/png;\r\n name=\"chrome.png\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment;\r\n filename=\"chrome.png\"\r\n\r\niVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAB+FBMVEUAAAA/mUPidDHiLi5Cn0Xk\r\nNTPmeUrkdUg/m0Q0pEfcpSbwaVdKskg+lUP4zA/iLi3msSHkOjVAmETdJSjtYFE/lkPnRj3sWUs8\r\nkkLeqCVIq0fxvhXqUkbVmSjwa1n1yBLepyX1xxP0xRXqUkboST9KukpHpUbuvRrzrhF/ljbwalju\r\nZFM4jELaoSdLtElJrUj1xxP6zwzfqSU4i0HYnydMtUlIqUfywxb60AxZqEXaoifgMCXptR9MtklH\r\npEY2iUHWnSjvvRr70QujkC+pUC/90glMuEnlOjVMt0j70QriLS1LtEnnRj3qUUXfIidOjsxAhcZF\r\no0bjNDH0xxNLr0dIrUdmntVTkMoyfL8jcLBRuErhJyrgKyb4zA/5zg3tYFBBmUTmQTnhMinruBzv\r\nvhnxwxZ/st+Ktt5zp9hqota2vtK6y9FemNBblc9HiMiTtMbFtsM6gcPV2r6dwroseLrMrbQrdLGd\r\nyKoobKbo3Zh+ynrgVllZulTsXE3rV0pIqUf42UVUo0JyjEHoS0HmsiHRGR/lmRz/1hjqnxjvpRWf\r\nwtOhusaz0LRGf7FEfbDVmqHXlJeW0pbXq5bec3fX0nTnzmuJuWvhoFFhm0FtrziBsjaAaDCYWC+u\r\nSi6jQS3FsSfLJiTirCOkuCG1KiG+wSC+GBvgyhTszQ64Z77KAAAARXRSTlMAIQRDLyUgCwsE6ebm\r\n5ubg2dLR0byXl4FDQzU1NDEuLSUgC+vr6urq6ubb29vb2tra2tG8vLu7u7uXl5eXgYGBgYGBLiUA\r\nLabIAAABsElEQVQoz12S9VPjQBxHt8VaOA6HE+AOzv1wd7pJk5I2adpCC7RUcHd3d3fXf5PvLkxh\r\neD++z+yb7GSRlwD/+Hj/APQCZWxM5M+goF+RMbHK594v+tPoiN1uHxkt+xzt9+R9wnRTZZQpXQ0T\r\n5uP1IQxToyOAZiQu5HEpjeA4SWIoksRxNiGC1tRZJ4LNxgHgnU5nJZBDvuDdl8lzQRBsQ+s9PZt7\r\ns7Pz8wsL39/DkIfZ4xlB2Gqsq62ta9oxVlVrNZpihFRpGO9fzQw1ms0NDWZz07iGkJmIFH8xxkc3\r\na/WWlubmFkv9AB2SEpDvKxbjidN2faseaNV3zoHXvv7wMODJdkOHAegweAfFPx4G67KluxzottCU\r\n9n8CUqXzcIQdXOytAHqXxomvykhEKN9EFutG22p//0rbNvHVxiJywa8yS2KDfV1dfbu31H8jF1RH\r\niTKtWYeHxUvq3bn0pyjCRaiRU6aDO+gb3aEfEeVNsDgm8zzLy9egPa7Qt8TSJdwhjplk06HH43ZN\r\nJ3s91KKCHQ5x4sw1fRGYDZ0n1L4FKb9/BP5JLYxToheoFCVxz57PPS8UhhEpLBVeAAAAAElFTkSu\r\nQmCC\r\n\r\n------=_NextPart_000_222_000--", $attachment->content);
|
||||
self::assertEquals(2535, $attachment->size);
|
||||
self::assertEquals(5, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("second.eml", $attachment->name);
|
||||
self::assertEquals('eml', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("From: from@there.com\r\nTo: to@here.com\r\nSubject: SECOND\r\nDate: Sat, 28 Apr 2018 13:37:30 -0400\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative;\r\n boundary=\"----=_NextPart_000_333_000\"\r\n\r\nThis is a multi-part message in MIME format.\r\n\r\n------=_NextPart_000_333_000\r\nContent-Type: text/plain;\r\n charset=\"UTF-8\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nT whom it may concern:\r\n------=_NextPart_000_333_000\r\nContent-Type: text/html;\r\n charset=\"UTF-8\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n<HTML><HEAD></HEAD>\r\n<BODY dir=3Dltr>\r\n<DIV>T whom it may concern:</DIV>\r\n</BODY></HTML>\r\n\r\n------=_NextPart_000_333_000--", $attachment->content);
|
||||
self::assertEquals(631, $attachment->size);
|
||||
self::assertEquals(6, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
39
plugins/php-imap/tests/fixtures/NullContentCharsetTest.php
vendored
Normal file
39
plugins/php-imap/tests/fixtures/NullContentCharsetTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* File: NullContentCharsetTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class NullContentCharsetTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class NullContentCharsetTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture null_content_charset.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("null_content_charset.eml");
|
||||
|
||||
self::assertEquals("test", $message->getSubject());
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertEquals("1.0", $message->mime_version);
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
82
plugins/php-imap/tests/fixtures/PecTest.php
vendored
Normal file
82
plugins/php-imap/tests/fixtures/PecTest.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*
|
||||
* File: PecTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
use Webklex\PHPIMAP\Support\AttachmentCollection;
|
||||
|
||||
/**
|
||||
* Class PecTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class PecTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture pec.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("pec.eml");
|
||||
|
||||
self::assertEquals("Certified", $message->subject);
|
||||
self::assertEquals("Signed", $message->getTextBody());
|
||||
self::assertEquals("<html><body>Signed</body></html>", $message->getHTMLBody());
|
||||
|
||||
self::assertEquals("2017-10-02 10:13:43", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("test@example.com", $message->from->first()->mail);
|
||||
self::assertEquals("test@example.com", $message->to->first()->mail);
|
||||
|
||||
$attachments = $message->attachments();
|
||||
|
||||
self::assertInstanceOf(AttachmentCollection::class, $attachments);
|
||||
self::assertCount(3, $attachments);
|
||||
|
||||
$attachment = $attachments[0];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("data.xml", $attachment->name);
|
||||
self::assertEquals('xml', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/xml", $attachment->content_type);
|
||||
self::assertEquals("<xml/>", $attachment->content);
|
||||
self::assertEquals(8, $attachment->size);
|
||||
self::assertEquals(4, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[1];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("postacert.eml", $attachment->name);
|
||||
self::assertEquals('eml', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("message/rfc822", $attachment->content_type);
|
||||
self::assertEquals("To: test@example.com\r\nFrom: test@example.com\r\nSubject: test-subject\r\nDate: Mon, 2 Oct 2017 12:13:50 +0200\r\nContent-Type: text/plain; charset=iso-8859-15; format=flowed\r\nContent-Transfer-Encoding: 7bit\r\n\r\ntest-content", $attachment->content);
|
||||
self::assertEquals(216, $attachment->size);
|
||||
self::assertEquals(5, $attachment->part_number);
|
||||
self::assertEquals("inline", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
|
||||
$attachment = $attachments[2];
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("smime.p7s", $attachment->name);
|
||||
self::assertEquals('p7s', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("application/x-pkcs7-signature", $attachment->content_type);
|
||||
self::assertEquals("1", $attachment->content);
|
||||
self::assertEquals(4, $attachment->size);
|
||||
self::assertEquals(7, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/PlainOnlyTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/PlainOnlyTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: PlainOnlyTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class PlainOnlyTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class PlainOnlyTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture plain_only.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("plain_only.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->getSubject());
|
||||
self::assertEquals("Hi", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
54
plugins/php-imap/tests/fixtures/PlainTextAttachmentTest.php
vendored
Normal file
54
plugins/php-imap/tests/fixtures/PlainTextAttachmentTest.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* File: PlainTextAttachmentTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
|
||||
/**
|
||||
* Class PlainTextAttachmentTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class PlainTextAttachmentTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture plain_text_attachment.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("plain_text_attachment.eml");
|
||||
|
||||
self::assertEquals("Plain text attachment", $message->subject);
|
||||
self::assertEquals("Test", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertEquals("2018-08-21 07:05:14", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
|
||||
self::assertCount(1, $message->attachments());
|
||||
|
||||
$attachment = $message->attachments()->first();
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("a.txt", $attachment->name);
|
||||
self::assertEquals('txt', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertNull($attachment->content_type);
|
||||
self::assertEquals("Hi!", $attachment->content);
|
||||
self::assertEquals(4, $attachment->size);
|
||||
self::assertEquals(2, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
54
plugins/php-imap/tests/fixtures/ReferencesTest.php
vendored
Normal file
54
plugins/php-imap/tests/fixtures/ReferencesTest.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* File: ReferencesTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class ReferencesTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class ReferencesTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture references.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("references.eml");
|
||||
|
||||
self::assertEquals("", $message->subject);
|
||||
self::assertEquals("Hi\r\nHow are you?", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertFalse($message->date->first());
|
||||
|
||||
self::assertEquals("b9e87bd5e661a645ed6e3b832828fcc5@example.com", $message->in_reply_to);
|
||||
self::assertEquals("", $message->from->first()->personal);
|
||||
self::assertEquals("UNKNOWN", $message->from->first()->host);
|
||||
self::assertEquals("no_host@UNKNOWN", $message->from->first()->mail);
|
||||
self::assertFalse($message->to->first());
|
||||
|
||||
self::assertEquals([
|
||||
"231d9ac57aec7d8c1a0eacfeab8af6f3@example.com",
|
||||
"08F04024-A5B3-4FDE-BF2C-6710DE97D8D9@example.com"
|
||||
], $message->getReferences()->all());
|
||||
|
||||
self::assertEquals([
|
||||
'This one: is "right" <ding@dong.com>',
|
||||
'No-address@UNKNOWN'
|
||||
], $message->cc->map(function($address){
|
||||
/** @var \Webklex\PHPIMAP\Address $address */
|
||||
return $address->full;
|
||||
}));
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/SimpleMultipartTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/SimpleMultipartTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: SimpleMultipartTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class SimpleMultipartTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class SimpleMultipartTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture simple_multipart.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("simple_multipart.eml");
|
||||
|
||||
self::assertEquals("test", $message->getSubject());
|
||||
self::assertEquals("MyPlain", $message->getTextBody());
|
||||
self::assertEquals("MyHtml", $message->getHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
55
plugins/php-imap/tests/fixtures/StructuredWithAttachmentTest.php
vendored
Normal file
55
plugins/php-imap/tests/fixtures/StructuredWithAttachmentTest.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* File: StructuredWithAttachmentTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Attachment;
|
||||
use Webklex\PHPIMAP\IMAP;
|
||||
|
||||
/**
|
||||
* Class StructuredWithAttachmentTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class StructuredWithAttachmentTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture structured_with_attachment.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("structured_with_attachment.eml");
|
||||
|
||||
self::assertEquals("Test", $message->getSubject());
|
||||
self::assertEquals("Test", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
|
||||
self::assertEquals("2017-09-29 08:55:23", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
|
||||
self::assertCount(1, $message->attachments());
|
||||
|
||||
$attachment = $message->attachments()->first();
|
||||
self::assertInstanceOf(Attachment::class, $attachment);
|
||||
self::assertEquals("MyFile.txt", $attachment->name);
|
||||
self::assertEquals('txt', $attachment->getExtension());
|
||||
self::assertEquals('text', $attachment->type);
|
||||
self::assertEquals("text/plain", $attachment->content_type);
|
||||
self::assertEquals("MyFileContent", $attachment->content);
|
||||
self::assertEquals(20, $attachment->size);
|
||||
self::assertEquals(2, $attachment->part_number);
|
||||
self::assertEquals("attachment", $attachment->disposition);
|
||||
self::assertNotEmpty($attachment->id);
|
||||
}
|
||||
}
|
||||
59
plugins/php-imap/tests/fixtures/UndefinedCharsetHeaderTest.php
vendored
Normal file
59
plugins/php-imap/tests/fixtures/UndefinedCharsetHeaderTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
* File: UndefinedCharsetHeaderTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
use Webklex\PHPIMAP\Address;
|
||||
|
||||
/**
|
||||
* Class UndefinedCharsetHeaderTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class UndefinedCharsetHeaderTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture undefined_charset_header.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("undefined_charset_header.eml");
|
||||
|
||||
self::assertEquals("<monitor@bla.bla>", $message->get("x-real-to"));
|
||||
self::assertEquals("1.0", $message->get("mime-version"));
|
||||
self::assertEquals("Mon, 27 Feb 2017 13:21:44 +0930", $message->get("Resent-Date"));
|
||||
self::assertEquals("<postmaster@bla.bla>", $message->get("Resent-From"));
|
||||
self::assertEquals("BlaBla", $message->get("X-Stored-In"));
|
||||
self::assertEquals("<info@bla.bla>", $message->get("Return-Path"));
|
||||
self::assertEquals([
|
||||
'from <postmaster@bla.bla> by bla.bla (CommuniGate Pro RULE 6.1.13) with RULE id 14057804; Mon, 27 Feb 2017 13:21:44 +0930',
|
||||
'from <postmaster@bla.bla> by bla.bla (CommuniGate Pro RULE 6.1.13) with RULE id 14057804'
|
||||
], $message->get("Received")->all());
|
||||
self::assertEquals(")", $message->getHTMLBody());
|
||||
self::assertFalse($message->hasTextBody());
|
||||
self::assertEquals("2017-02-27 03:51:29", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
|
||||
$from = $message->from->first();
|
||||
self::assertInstanceOf(Address::class, $from);
|
||||
|
||||
self::assertEquals("myGov", $from->personal);
|
||||
self::assertEquals("info", $from->mailbox);
|
||||
self::assertEquals("bla.bla", $from->host);
|
||||
self::assertEquals("info@bla.bla", $from->mail);
|
||||
self::assertEquals("myGov <info@bla.bla>", $from->full);
|
||||
|
||||
self::assertEquals("sales@bla.bla", $message->to->first()->mail);
|
||||
self::assertEquals("Submit your tax refund | Australian Taxation Office.", $message->subject);
|
||||
self::assertEquals("201702270351.BGF77614@bla.bla", $message->message_id);
|
||||
}
|
||||
}
|
||||
42
plugins/php-imap/tests/fixtures/UndisclosedRecipientsMinusTest.php
vendored
Normal file
42
plugins/php-imap/tests/fixtures/UndisclosedRecipientsMinusTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* File: PlainOnlyTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class PlainOnlyTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class UndisclosedRecipientsMinusTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture undisclosed_recipients_minus.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("undisclosed_recipients_minus.eml");
|
||||
|
||||
self::assertEquals("test", $message->subject);
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from);
|
||||
self::assertEquals([
|
||||
"undisclosed-recipients",
|
||||
""
|
||||
], $message->to->map(function ($item) {
|
||||
return $item->mailbox;
|
||||
}));
|
||||
}
|
||||
}
|
||||
42
plugins/php-imap/tests/fixtures/UndisclosedRecipientsSpaceTest.php
vendored
Normal file
42
plugins/php-imap/tests/fixtures/UndisclosedRecipientsSpaceTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* File: UndisclosedRecipientsSpaceTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class UndisclosedRecipientsSpaceTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class UndisclosedRecipientsSpaceTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture undisclosed_recipients_space.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("undisclosed_recipients_space.eml");
|
||||
|
||||
self::assertEquals("test", $message->subject);
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from);
|
||||
self::assertEquals([
|
||||
"Undisclosed recipients",
|
||||
""
|
||||
], $message->to->map(function ($item) {
|
||||
return $item->mailbox;
|
||||
}));
|
||||
}
|
||||
}
|
||||
42
plugins/php-imap/tests/fixtures/UndisclosedRecipientsTest.php
vendored
Normal file
42
plugins/php-imap/tests/fixtures/UndisclosedRecipientsTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* File: UndisclosedRecipientsTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class UndisclosedRecipientsTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class UndisclosedRecipientsTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture undisclosed_recipients.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("undisclosed_recipients.eml");
|
||||
|
||||
self::assertEquals("test", $message->subject);
|
||||
self::assertEquals("Hi!", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from);
|
||||
self::assertEquals([
|
||||
"Undisclosed Recipients",
|
||||
""
|
||||
], $message->to->map(function ($item) {
|
||||
return $item->mailbox;
|
||||
}));
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/UnknownEncodingTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/UnknownEncodingTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: UnknownEncodingTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class UnknownEncodingTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class UnknownEncodingTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture unknown_encoding.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("unknown_encoding.eml");
|
||||
|
||||
self::assertEquals("test", $message->getSubject());
|
||||
self::assertEquals("MyPlain", $message->getTextBody());
|
||||
self::assertEquals("MyHtml", $message->getHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/WithoutCharsetPlainOnlyTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/WithoutCharsetPlainOnlyTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: WithoutCharsetPlainOnlyTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class WithoutCharsetPlainOnlyTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class WithoutCharsetPlainOnlyTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture without_charset_plain_only.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("without_charset_plain_only.eml");
|
||||
|
||||
self::assertEquals("Nuu", $message->getSubject());
|
||||
self::assertEquals("Hi", $message->getTextBody());
|
||||
self::assertFalse($message->hasHTMLBody());
|
||||
self::assertEquals("2017-09-13 11:05:45", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
37
plugins/php-imap/tests/fixtures/WithoutCharsetSimpleMultipartTest.php
vendored
Normal file
37
plugins/php-imap/tests/fixtures/WithoutCharsetSimpleMultipartTest.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* File: WithoutCharsetSimpleMultipartTest.php
|
||||
* Category: -
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 09.03.23 02:24
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
namespace Tests\fixtures;
|
||||
|
||||
/**
|
||||
* Class WithoutCharsetSimpleMultipartTest
|
||||
*
|
||||
* @package Tests\fixtures
|
||||
*/
|
||||
class WithoutCharsetSimpleMultipartTest extends FixtureTestCase {
|
||||
|
||||
/**
|
||||
* Test the fixture without_charset_simple_multipart.eml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFixture() : void {
|
||||
$message = $this->getFixture("without_charset_simple_multipart.eml");
|
||||
|
||||
self::assertEquals("test", $message->getSubject());
|
||||
self::assertEquals("MyPlain", $message->getTextBody());
|
||||
self::assertEquals("MyHtml", $message->getHTMLBody());
|
||||
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
|
||||
self::assertEquals("from@there.com", $message->from->first()->mail);
|
||||
self::assertEquals("to@here.com", $message->to->first()->mail);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user