feat: implement content cache

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-09-29 19:56:30 -04:00
parent d28800a04e
commit 0250b5a847
10 changed files with 511 additions and 8 deletions
+34
View File
@@ -78,6 +78,40 @@ final class FetchMessageParserTest extends TestCase
$this->assertSame(['1' => 'Hello wor'], $message->bodySections());
}
public function testTruncatedSectionsAreReported(): void
{
$complete = FetchMessageParser::parse($this->fetchResponse(
self::MIXED_STRUCTURE,
'BODY[TEXT]',
self::ALTERNATIVE_PREFIX . "<p>Hello</p>\r\n--alt--\r\n--mix--\r\n",
));
$cutInHtml = FetchMessageParser::parse($this->fetchResponse(
self::MIXED_STRUCTURE,
'BODY[TEXT]<0>',
self::ALTERNATIVE_PREFIX . '<p>Hello wor',
));
$cutInAttachment = FetchMessageParser::parse($this->fetchResponse(
self::MIXED_STRUCTURE,
'BODY[TEXT]<0>',
self::ALTERNATIVE_PREFIX . "<p>Hello</p>\r\n--alt--\r\n--mix\r\nContent-Type: application/pdf\r\n\r\nJVBE",
));
$this->assertSame([], $complete->truncatedSections());
$this->assertSame(['1.2'], $cutInHtml->truncatedSections());
$this->assertSame([], $cutInAttachment->truncatedSections());
}
public function testTruncatedSinglePartBodyIsReportedBySize(): void
{
$structure = '("TEXT" "PLAIN" ("CHARSET" "UTF-8") NIL NIL "7BIT" 11 1)';
$partial = FetchMessageParser::parse($this->fetchResponse($structure, 'BODY[TEXT]<0>', 'Hello'));
$complete = FetchMessageParser::parse($this->fetchResponse($structure, 'BODY[TEXT]', 'Hello world'));
$this->assertSame(['1'], $partial->truncatedSections());
$this->assertSame([], $complete->truncatedSections());
}
private function fetchResponse(string $bodyStructure, string $section, string $body): string
{
return sprintf(