Reintroduce Webklex IMAP for ticket processing as PHP-IMAP is no longer being developed. This is optional for now and considered beta can be found in cron/ticket_email_parser.php

This commit is contained in:
johnnyq
2025-09-10 14:27:46 -04:00
parent 981fb9585d
commit ce7d84aa2f
2035 changed files with 174115 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
/*
* File: Issue355Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 10.01.23 10:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Message;
class Issue275Test extends TestCase {
public function testIssueEmail1() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-275.eml"]);
$message = Message::fromFile($filename);
self::assertSame("Testing 123", (string)$message->subject);
self::assertSame("Asdf testing123 this is a body", $message->getTextBody());
}
public function testIssueEmail2() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-275-2.eml"]);
$message = Message::fromFile($filename);
$body = "Test\r\n\r\nMed venlig hilsen\r\nMartin Larsen\r\nFeline Holidays A/S\r\nTlf 78 77 04 12";
self::assertSame("Test 1017", (string)$message->subject);
self::assertSame($body, $message->getTextBody());
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*
* File: Issue355Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 10.01.23 10:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Config;
use Webklex\PHPIMAP\Header;
class Issue355Test extends TestCase {
public function testIssue() {
$raw_header = "Subject: =?UTF-8?Q?Re=3A_Uppdaterat_=C3=A4rende_=28447899=29=2C_kostnader_f=C3=B6r_hj=C3=A4?= =?UTF-8?Q?lp_med_stadge=C3=A4ndring_enligt_ny_lagstiftning?=\r\n";
$header = new Header($raw_header, Config::make());
$subject = $header->get("subject");
$this->assertEquals("Re: Uppdaterat ärende (447899), kostnader för hjälp med stadgeändring enligt ny lagstiftning", $subject->toString());
}
}

View File

@@ -0,0 +1,61 @@
<?php
/*
* File: Issue355Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 10.01.23 10:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use Tests\live\LiveMailboxTestCase;
use Webklex\PHPIMAP\Exceptions\AuthFailedException;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\EventNotFoundException;
use Webklex\PHPIMAP\Exceptions\FolderFetchingException;
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\MessageFlagException;
use Webklex\PHPIMAP\Exceptions\MessageHeaderFetchingException;
use Webklex\PHPIMAP\Exceptions\MessageNotFoundException;
use Webklex\PHPIMAP\Exceptions\ResponseException;
use Webklex\PHPIMAP\Exceptions\RuntimeException;
class Issue379Test extends LiveMailboxTestCase {
/**
* Test issue #379 - Message::getSize() added
* @return void
* @throws AuthFailedException
* @throws ConnectionFailedException
* @throws EventNotFoundException
* @throws FolderFetchingException
* @throws ImapBadRequestException
* @throws ImapServerErrorException
* @throws InvalidMessageDateException
* @throws MessageContentFetchingException
* @throws MessageFlagException
* @throws MessageHeaderFetchingException
* @throws MessageNotFoundException
* @throws ResponseException
* @throws RuntimeException
* @throws MaskNotFoundException
*/
public function testIssue(): void {
$folder = $this->getFolder('INBOX');
$message = $this->appendMessageTemplate($folder, "plain.eml");
$this->assertEquals(214, $message->getSize());
// Clean up
$this->assertTrue($message->delete(true));
}
}

View File

@@ -0,0 +1,33 @@
<?php
/*
* File: Issue382Test.php
* Category: Test
* Author: M.Goldenbaum
* Created: 24.06.23 00:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Message;
class Issue382Test extends TestCase {
public function testIssueEmail() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-382.eml"]);
$message = Message::fromFile($filename);
$from = $message->from->first();
self::assertSame("Mail Delivery System", $from->personal);
self::assertSame("MAILER-DAEMON", $from->mailbox);
self::assertSame("mta-09.someserver.com", $from->host);
self::assertSame("MAILER-DAEMON@mta-09.someserver.com", $from->mail);
self::assertSame("Mail Delivery System <MAILER-DAEMON@mta-09.someserver.com>", $from->full);
}
}

View File

@@ -0,0 +1,69 @@
<?php
/*
* File: Issue355Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 10.01.23 10:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use Tests\live\LiveMailboxTestCase;
use Webklex\PHPIMAP\Exceptions\AuthFailedException;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\EventNotFoundException;
use Webklex\PHPIMAP\Exceptions\FolderFetchingException;
use Webklex\PHPIMAP\Exceptions\ImapBadRequestException;
use Webklex\PHPIMAP\Exceptions\ImapServerErrorException;
use Webklex\PHPIMAP\Exceptions\MaskNotFoundException;
use Webklex\PHPIMAP\Exceptions\ResponseException;
use Webklex\PHPIMAP\Exceptions\RuntimeException;
use Webklex\PHPIMAP\Folder;
class Issue383Test extends LiveMailboxTestCase {
/**
* Test issue #383 - Does not work when a folder name contains umlauts: Entwürfe
* @return void
* @throws AuthFailedException
* @throws ConnectionFailedException
* @throws EventNotFoundException
* @throws FolderFetchingException
* @throws ImapBadRequestException
* @throws ImapServerErrorException
* @throws ResponseException
* @throws RuntimeException
* @throws MaskNotFoundException
*/
public function testIssue(): void {
$client = $this->getClient();
$client->connect();
$delimiter = $this->getManager()->getConfig()->get("options.delimiter");
$folder_path = implode($delimiter, ['INBOX', 'Entwürfe+']);
$folder = $client->getFolder($folder_path);
$this->deleteFolder($folder);
$folder = $client->createFolder($folder_path, false);
self::assertInstanceOf(Folder::class, $folder);
$folder = $this->getFolder($folder_path);
self::assertInstanceOf(Folder::class, $folder);
$this->assertEquals('Entwürfe+', $folder->name);
$this->assertEquals($folder_path, $folder->full_name);
$folder_path = implode($delimiter, ['INBOX', 'Entw&APw-rfe+']);
$this->assertEquals($folder_path, $folder->path);
// Clean up
if ($this->deleteFolder($folder) === false) {
$this->fail("Could not delete folder: " . $folder->path);
}
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* File: Issue393Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 10.01.23 10:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use Tests\live\LiveMailboxTestCase;
use Webklex\PHPIMAP\Exceptions\AuthFailedException;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\EventNotFoundException;
use Webklex\PHPIMAP\Exceptions\FolderFetchingException;
use Webklex\PHPIMAP\Exceptions\ImapBadRequestException;
use Webklex\PHPIMAP\Exceptions\ImapServerErrorException;
use Webklex\PHPIMAP\Exceptions\MaskNotFoundException;
use Webklex\PHPIMAP\Exceptions\ResponseException;
use Webklex\PHPIMAP\Exceptions\RuntimeException;
use Webklex\PHPIMAP\Folder;
class Issue393Test extends LiveMailboxTestCase {
/**
* Test issue #393 - "Empty response" when calling getFolders()
* @return void
* @throws AuthFailedException
* @throws ConnectionFailedException
* @throws EventNotFoundException
* @throws FolderFetchingException
* @throws ImapBadRequestException
* @throws ImapServerErrorException
* @throws ResponseException
* @throws RuntimeException
* @throws MaskNotFoundException
*/
public function testIssue(): void {
$client = $this->getClient();
$client->connect();
$delimiter = $this->getManager()->getConfig()->get("options.delimiter");
$pattern = implode($delimiter, ['doesnt_exist', '%']);
$folder = $client->getFolder('doesnt_exist');
$this->deleteFolder($folder);
$folders = $client->getFolders(true, $pattern, true);
self::assertCount(0, $folders);
try {
$client->getFolders(true, $pattern, false);
$this->fail('Expected FolderFetchingException::class exception not thrown');
} catch (FolderFetchingException $e) {
self::assertInstanceOf(FolderFetchingException::class, $e);
}
}
}

View File

@@ -0,0 +1,27 @@
<?php
/*
* File: Issue401Test.php
* Category: Test
* Author: M.Goldenbaum
* Created: 23.06.23 22:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Message;
class Issue401Test extends TestCase {
public function testIssueEmail() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-401.eml"]);
$message = Message::fromFile($filename);
self::assertSame("1;00pm Client running few minutes late", (string)$message->subject);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* File: Issue407Test.php
* Category: Test
* Author: M.Goldenbaum
* Created: 23.06.23 21:40
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Tests\live\LiveMailboxTestCase;
use Webklex\PHPIMAP\Folder;
use Webklex\PHPIMAP\IMAP;
use Webklex\PHPIMAP\Message;
class Issue407Test extends LiveMailboxTestCase {
/**
* @return void
* @throws \Webklex\PHPIMAP\Exceptions\AuthFailedException
* @throws \Webklex\PHPIMAP\Exceptions\ConnectionFailedException
* @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
* @throws \Webklex\PHPIMAP\Exceptions\FolderFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\ImapBadRequestException
* @throws \Webklex\PHPIMAP\Exceptions\ImapServerErrorException
* @throws \Webklex\PHPIMAP\Exceptions\InvalidMessageDateException
* @throws \Webklex\PHPIMAP\Exceptions\MaskNotFoundException
* @throws \Webklex\PHPIMAP\Exceptions\MessageContentFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
* @throws \Webklex\PHPIMAP\Exceptions\MessageHeaderFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\ResponseException
* @throws \Webklex\PHPIMAP\Exceptions\RuntimeException
*/
public function testIssue() {
$folder = $this->getFolder('INBOX');
self::assertInstanceOf(Folder::class, $folder);
$message = $this->appendMessageTemplate($folder, "plain.eml");
self::assertInstanceOf(Message::class, $message);
$message->setFlag("Seen");
$flags = $this->getClient()->getConnection()->flags($message->uid, IMAP::ST_UID)->validatedData();
self::assertIsArray($flags);
self::assertSame(1, count($flags));
self::assertSame("\\Seen", $flags[$message->uid][0]);
$message->delete();
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* File: Issue410Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 23.06.23 20:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Tests\fixtures\FixtureTestCase;
use Webklex\PHPIMAP\Attachment;
use Webklex\PHPIMAP\ClientManager;
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\Exceptions\SpoofingAttemptDetectedException;
use Webklex\PHPIMAP\Message;
class Issue40Test extends FixtureTestCase {
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws InvalidMessageDateException
* @throws ConnectionFailedException
* @throws \ReflectionException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws MaskNotFoundException
*/
public function testIssueEmail() {
$message = $this->getFixture("issue-40.eml");
self::assertSame("Zly from", (string)$message->subject);
self::assertSame([
'personal' => '',
'mailbox' => 'faked_sender',
'host' => 'sender_domain.pl',
'mail' => 'faked_sender@sender_domain.pl',
'full' => 'faked_sender@sender_domain.pl',
], $message->from->first()->toArray());
self::assertSame([
'personal' => '<real_sender@sender_domain.pl>',
'mailbox' => 'real_sender',
'host' => 'sender_domain.pl',
'mail' => 'real_sender@sender_domain.pl',
'full' => '<real_sender@sender_domain.pl> <real_sender@sender_domain.pl>',
], (array)$message->return_path->first());
self::assertSame(true, $message->spoofed->first());
$config = $message->getConfig();
self::assertSame(false, $config->get("security.detect_spoofing_exception"));
$config->set("security.detect_spoofing_exception", true);
self::assertSame(true, $config->get("security.detect_spoofing_exception"));
$this->expectException(SpoofingAttemptDetectedException::class);
$this->getFixture("issue-40.eml", $config);
}
}

View File

@@ -0,0 +1,111 @@
<?php
/*
* File: Issue410Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 23.06.23 20:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Tests\fixtures\FixtureTestCase;
use Webklex\PHPIMAP\Attachment;
use Webklex\PHPIMAP\ClientManager;
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;
class Issue410Test extends FixtureTestCase {
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws InvalidMessageDateException
* @throws ConnectionFailedException
* @throws \ReflectionException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws MaskNotFoundException
*/
public function testIssueEmail() {
$message = $this->getFixture("issue-410.eml");
self::assertSame("☆第132号 「ガーデン&エクステリア」専門店のためのQ&Aサロン 【月刊エクステリア・ワーク】", (string)$message->subject);
$attachments = $message->getAttachments();
self::assertSame(1, $attachments->count());
$attachment = $attachments->first();
self::assertSame("☆第132号 「ガーデン&エクステリア」専門店のためのQ&Aサロン 【月刊エクステリア・ワーク】", $attachment->filename);
self::assertSame("☆第132号 「ガーデン&エクステリア」専門店のためのQ&Aサロン 【月刊エクステリア・ワーク】", $attachment->name);
}
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws InvalidMessageDateException
* @throws ConnectionFailedException
* @throws \ReflectionException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws MaskNotFoundException
*/
public function testIssueEmailB() {
$message = $this->getFixture("issue-410b.eml");
self::assertSame("386 - 400021804 - 19., Heiligenstädter Straße 80 - 0819306 - Anfrage Vergabevorschlag", (string)$message->subject);
$attachments = $message->getAttachments();
self::assertSame(1, $attachments->count());
$attachment = $attachments->first();
self::assertSame("2021_Mängelliste_0819306.xlsx", $attachment->description);
self::assertSame("2021_Mängelliste_0819306.xlsx", $attachment->filename);
self::assertSame("2021_Mängelliste_0819306.xlsx", $attachment->name);
}
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws ConnectionFailedException
* @throws InvalidMessageDateException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws \ReflectionException
* @throws MaskNotFoundException
*/
public function testIssueEmailSymbols() {
$message = $this->getFixture("issue-410symbols.eml");
$attachments = $message->getAttachments();
self::assertSame(1, $attachments->count());
/** @var Attachment $attachment */
$attachment = $attachments->first();
self::assertSame("Checkliste 10.,DAVIDGASSE 76-80;2;2.pdf", $attachment->description);
self::assertSame("Checkliste 10.,DAVIDGASSE 76-80;2;2.pdf", $attachment->name);
self::assertSame("Checkliste 10.,DAVIDGASSE 76-80;2;2.pdf", $attachment->filename);
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* File: Issue413Test.php
* Category: Test
* Author: M.Goldenbaum
* Created: 23.06.23 21:09
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Config;
use Webklex\PHPIMAP\Message;
class Issue412Test extends TestCase {
public function testIssueEmail() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-412.eml"]);
$message = Message::fromFile($filename);
self::assertSame("RE: TEST MESSAGE", (string)$message->subject);
self::assertSame("64254d63e92a36ee02c760676351e60a", md5($message->getTextBody()));
self::assertSame("2e4de288f6a1ed658548ed11fcdb1d79", md5($message->getHTMLBody()));
self::assertSame(0, $message->attachments()->count());
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*
* File: Issue413Test.php
* Category: Test
* Author: M.Goldenbaum
* Created: 23.06.23 21:09
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Tests\live\LiveMailboxTestCase;
use Webklex\PHPIMAP\Config;
use Webklex\PHPIMAP\Folder;
use Webklex\PHPIMAP\Message;
class Issue413Test extends LiveMailboxTestCase {
/**
* Live server test
*
* @return void
* @throws \Webklex\PHPIMAP\Exceptions\AuthFailedException
* @throws \Webklex\PHPIMAP\Exceptions\ConnectionFailedException
* @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
* @throws \Webklex\PHPIMAP\Exceptions\FolderFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\GetMessagesFailedException
* @throws \Webklex\PHPIMAP\Exceptions\ImapBadRequestException
* @throws \Webklex\PHPIMAP\Exceptions\ImapServerErrorException
* @throws \Webklex\PHPIMAP\Exceptions\InvalidMessageDateException
* @throws \Webklex\PHPIMAP\Exceptions\MaskNotFoundException
* @throws \Webklex\PHPIMAP\Exceptions\MessageContentFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
* @throws \Webklex\PHPIMAP\Exceptions\MessageHeaderFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\MessageNotFoundException
* @throws \Webklex\PHPIMAP\Exceptions\ResponseException
* @throws \Webklex\PHPIMAP\Exceptions\RuntimeException
*/
public function testLiveIssueEmail() {
$folder = $this->getFolder('INBOX');
self::assertInstanceOf(Folder::class, $folder);
/** @var Message $message */
$_message = $this->appendMessageTemplate($folder, 'issue-413.eml');
$message = $folder->messages()->getMessageByMsgn($_message->msgn);
self::assertEquals($message->uid, $_message->uid);
self::assertSame("Test Message", (string)$message->subject);
self::assertSame("This is just a test, so ignore it (if you can!)\r\n\r\nTony Marston", $message->getTextBody());
$message->delete();
}
/**
* Static parsing test
*
* @return void
* @throws \ReflectionException
* @throws \Webklex\PHPIMAP\Exceptions\AuthFailedException
* @throws \Webklex\PHPIMAP\Exceptions\ConnectionFailedException
* @throws \Webklex\PHPIMAP\Exceptions\ImapBadRequestException
* @throws \Webklex\PHPIMAP\Exceptions\ImapServerErrorException
* @throws \Webklex\PHPIMAP\Exceptions\InvalidMessageDateException
* @throws \Webklex\PHPIMAP\Exceptions\MaskNotFoundException
* @throws \Webklex\PHPIMAP\Exceptions\MessageContentFetchingException
* @throws \Webklex\PHPIMAP\Exceptions\ResponseException
* @throws \Webklex\PHPIMAP\Exceptions\RuntimeException
*/
public function testIssueEmail() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-413.eml"]);
$message = Message::fromFile($filename);
self::assertSame("Test Message", (string)$message->subject);
self::assertSame("This is just a test, so ignore it (if you can!)\r\n\r\nTony Marston", $message->getTextBody());
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* File: Issue410Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 23.06.23 20:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Message;
class Issue414Test extends TestCase {
public function testIssueEmail() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "issue-414.eml"]);
$message = Message::fromFile($filename);
self::assertSame("Test", (string)$message->subject);
$attachments = $message->getAttachments();
self::assertSame(2, $attachments->count());
$attachment = $attachments->first();
self::assertEmpty($attachment->description);
self::assertSame("exampleMyFile.txt", $attachment->filename);
self::assertSame("exampleMyFile.txt", $attachment->name);
self::assertSame("be62f7e6", $attachment->id);
$attachment = $attachments->last();
self::assertEmpty($attachment->description);
self::assertSame("phpfoo", $attachment->filename);
self::assertSame("phpfoo", $attachment->name);
self::assertSame("12e1d38b", $attachment->hash);
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* File: Issue355Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 10.01.23 10:48
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Config;
use Webklex\PHPIMAP\Header;
class Issue420Test extends TestCase {
public function testIssue() {
$raw_header = "Subject: =?UTF-8?B?VGlja2V0IE5vOiBb7aC97bOpMTddIE1haWxib3ggSW5ib3ggLSAoMTcpIEluY29taW5nIGZhaWxlZCBtZXNzYWdlcw==?=\r\n";
$header = new Header($raw_header, Config::make());
$subject = $header->get("subject");
// Ticket No: [<5B><>17] Mailbox Inbox - (17) Incoming failed messages
$this->assertEquals('Ticket No: [??17] Mailbox Inbox - (17) Incoming failed messages', utf8_decode($subject->toString()));
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* File: Issue462Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 23.06.23 20:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use Tests\fixtures\FixtureTestCase;
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;
class Issue462Test extends FixtureTestCase {
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws InvalidMessageDateException
* @throws ConnectionFailedException
* @throws \ReflectionException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws MaskNotFoundException
*/
public function testIssueEmail() {
$config = Config::make();
$config->set('options.rfc822', false);
$message = $this->getFixture("issue-462.eml", $config);
self::assertSame("Undeliverable: Some subject", (string)$message->subject);
self::assertSame("postmaster@ <sending_domain.tld postmaster@sending_domain.tld>", (string)$message->from->first());
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Webklex\PHPIMAP\Client;
use Webklex\PHPIMAP\Folder;
class Issue469Test extends TestCase {
/**
* Test issue #469 - Case sensitive \NoSelect flag check doesn't work for Gmail
*/
public function testIssue(): void {
$client = $this->createStub(Client::class);
$folder_name = '[Gmail]';
$delimiter = '/';
$attributes = [
'\NoInferiors',
'\NoSelect',
];
$folder = new Folder($client, $folder_name, $delimiter, $attributes);
$attributes_lowercase = [
'\Noinferiors',
'\Noselect',
];
$folder_lowercase = new Folder($client, $folder_name, $delimiter, $attributes_lowercase);
self::assertSame(
$folder->no_inferiors,
$folder_lowercase->no_inferiors,
'The parsed "\NoInferiors" attribute does not match the parsed "\Noinferiors" attribute'
);
self::assertSame(
$folder->no_select,
$folder_lowercase->no_select,
'The parsed "\NoSelect" attribute does not match the parsed "\Noselect" attribute'
);
}
}

View File

@@ -0,0 +1,50 @@
<?php
/*
* File: Issue410Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 23.06.23 20:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Tests\fixtures\FixtureTestCase;
use Webklex\PHPIMAP\Attachment;
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\EncodingAliases;
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;
class Issue511Test extends FixtureTestCase {
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws InvalidMessageDateException
* @throws ConnectionFailedException
* @throws \ReflectionException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws MaskNotFoundException
*/
public function testIssueEmail() {
$message = $this->getFixture("issue-511.eml");
self::assertSame("RE: [EXTERNAL] Re: Lorem Ipsum /40 one", (string)$message->subject);
self::assertSame("COMPANYNAME | usługi <sender@sender_domain.tld>", (string)$message->from->first());
}
}

View File

@@ -0,0 +1,61 @@
<?php
/*
* File: Issue410Test.php
* Category: -
* Author: M.Goldenbaum
* Created: 23.06.23 20:41
* Updated: -
*
* Description:
* -
*/
namespace Tests\issues;
use PHPUnit\Framework\TestCase;
use Tests\fixtures\FixtureTestCase;
use Webklex\PHPIMAP\Attachment;
use Webklex\PHPIMAP\ClientManager;
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;
class Issue544Test extends FixtureTestCase {
/**
* @throws RuntimeException
* @throws MessageContentFetchingException
* @throws ResponseException
* @throws ImapBadRequestException
* @throws InvalidMessageDateException
* @throws ConnectionFailedException
* @throws \ReflectionException
* @throws ImapServerErrorException
* @throws AuthFailedException
* @throws MaskNotFoundException
*/
public function testIssueEmail() {
$message = $this->getFixture("issue-544.eml");
self::assertSame("Test bad boundary", (string)$message->subject);
$attachments = $message->getAttachments();
self::assertSame(1, $attachments->count());
/** @var Attachment $attachment */
$attachment = $attachments->first();
self::assertSame("file.pdf", $attachment->name);
self::assertSame("file.pdf", $attachment->filename);
self::assertStringStartsWith("%PDF-1.4", $attachment->content);
self::assertStringEndsWith("%%EOF\n", $attachment->content);
self::assertSame(14938, $attachment->size);
}
}