Skip to content

Commit 473e6ea

Browse files
committed
Validate fake synchronization checkpoints
1 parent 75d66c1 commit 473e6ea

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/Testing/FakeMessageQuery.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use DirectoryTree\ImapEngine\UidOrder;
2121
use DirectoryTree\ImapEngine\Vanished;
2222
use Illuminate\Support\ItemNotFoundException;
23+
use InvalidArgumentException;
2324

2425
class FakeMessageQuery implements MessageQueryInterface
2526
{
@@ -56,6 +57,10 @@ public function changesSince(int $modSequence, array|int $uids, bool $vanished =
5657
return new FetchResult;
5758
}
5859

60+
if ($modSequence < 0) {
61+
throw new InvalidArgumentException('Invalid IMAP modification sequence.');
62+
}
63+
5964
$capability = $vanished ? 'QRESYNC' : 'CONDSTORE';
6065

6166
$mailbox = $this->folder->mailbox();

‎tests/Unit/Testing/FakeMessageQueryTest.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,13 @@
347347
expect($result->vanishedUids())->toBe([]);
348348
});
349349

350+
test('fake synchronization rejects negative checkpoints for a non-empty uid set', function () {
351+
$folder = new FakeFolder('INBOX', messages: [new FakeMessage(7)]);
352+
353+
expect(fn () => $folder->messages()->changesSince(-1, [7]))
354+
->toThrow(InvalidArgumentException::class);
355+
});
356+
350357
test('fake synchronization returns messages that vanished after the checkpoint', function () {
351358
$folder = new FakeFolder(
352359
'INBOX',

0 commit comments

Comments
 (0)