|
2 | 2 |
|
3 | 3 | use DirectoryTree\ImapEngine\Connection\ImapConnection; |
4 | 4 | use DirectoryTree\ImapEngine\Connection\Streams\FakeStream; |
| 5 | +use DirectoryTree\ImapEngine\Enums\ImapFetchIdentifier; |
5 | 6 | use DirectoryTree\ImapEngine\Exceptions\ImapCommandException; |
6 | 7 | use DirectoryTree\ImapEngine\Exceptions\ImapConnectionException; |
7 | 8 | use DirectoryTree\ImapEngine\Exceptions\ImapConnectionFailedException; |
|
441 | 442 | expect($response)->toBeInstanceOf(\DirectoryTree\ImapEngine\Collections\ResponseCollection::class); |
442 | 443 | }); |
443 | 444 |
|
444 | | -test('uid fetch', function () { |
| 445 | +test('uid fetch with uid', function () { |
445 | 446 | $stream = new FakeStream; |
446 | 447 | $stream->open(); |
447 | 448 |
|
|
454 | 455 | $connection = new ImapConnection($stream); |
455 | 456 | $connection->connect('imap.example.com'); |
456 | 457 |
|
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); |
458 | 479 |
|
459 | 480 | $stream->assertWritten('TAG1 FETCH 1 (UID)'); |
460 | 481 |
|
|
0 commit comments