Skip to content

Commit 07b0615

Browse files
committed
Add and update test
1 parent 16b2244 commit 07b0615

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/Unit/Connection/ImapConnectionTest.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use DirectoryTree\ImapEngine\Connection\ImapConnection;
44
use DirectoryTree\ImapEngine\Connection\Streams\FakeStream;
5+
use DirectoryTree\ImapEngine\Enums\ImapFetchIdentifier;
56
use DirectoryTree\ImapEngine\Exceptions\ImapCommandException;
67
use DirectoryTree\ImapEngine\Exceptions\ImapConnectionException;
78
use DirectoryTree\ImapEngine\Exceptions\ImapConnectionFailedException;
@@ -441,7 +442,7 @@
441442
expect($response)->toBeInstanceOf(\DirectoryTree\ImapEngine\Collections\ResponseCollection::class);
442443
});
443444

444-
test('uid fetch', function () {
445+
test('uid fetch with uid', function () {
445446
$stream = new FakeStream;
446447
$stream->open();
447448

@@ -454,7 +455,27 @@
454455
$connection = new ImapConnection($stream);
455456
$connection->connect('imap.example.com');
456457

457-
$responses = $connection->uid(1);
458+
$responses = $connection->uid(1, ImapFetchIdentifier::Uid);
459+
460+
$stream->assertWritten('TAG1 UID FETCH 1 (UID)');
461+
462+
expect((string) $responses->first())->toBe('* 1 FETCH (UID 123)');
463+
});
464+
465+
test('uid fetch with message number', function () {
466+
$stream = new FakeStream;
467+
$stream->open();
468+
469+
$stream->feed([
470+
'* OK Welcome to IMAP',
471+
'* 1 FETCH (UID 123)',
472+
'TAG1 OK UID FETCH completed',
473+
]);
474+
475+
$connection = new ImapConnection($stream);
476+
$connection->connect('imap.example.com');
477+
478+
$responses = $connection->uid(1, ImapFetchIdentifier::MessageNumber);
458479

459480
$stream->assertWritten('TAG1 FETCH 1 (UID)');
460481

0 commit comments

Comments
 (0)