Skip to content

Commit e5f0d0f

Browse files
committed
Add test
1 parent 8eb5b50 commit e5f0d0f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/Unit/BodyStructureTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,26 @@ function parseBodyStructureResponse(string $response): ListData
152152
expect($imagePart->id())->toBe('<cid123>');
153153
});
154154

155+
test('it does not emit warnings when non-scalar tokens appear in message/rfc822 structure fields', function () {
156+
$listData = parseBodyStructureResponse(
157+
'* 1 FETCH (BODYSTRUCTURE ("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 3456 (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("charset" "utf-8") NIL NIL "7BIT" 100 10 NIL NIL NIL) 42) UID 1)'
158+
);
159+
160+
set_error_handler(static function (int $severity, string $message, string $file, int $line): never {
161+
throw new ErrorException($message, 0, $severity, $file, $line);
162+
});
163+
164+
try {
165+
$part = BodyStructurePart::fromListData($listData);
166+
} finally {
167+
restore_error_handler();
168+
}
169+
170+
expect($part->contentType())->toBe('message/rfc822');
171+
expect($part->size())->toBe(3456);
172+
expect($part->lines())->toBeNull();
173+
});
174+
155175
test('it makes BodyStructureCollection countable', function () {
156176
$listData = parseBodyStructureResponse(
157177
'* 1 FETCH (BODYSTRUCTURE (("text" "plain" ("charset" "utf-8") NIL NIL "7bit" 100 5 NIL NIL NIL) ("text" "html" ("charset" "utf-8") NIL NIL "7bit" 200 10 NIL NIL NIL) "alternative" ("boundary" "abc") NIL NIL) UID 1)'

0 commit comments

Comments
 (0)