Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Connection/ImapQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ public function header(string $header, string $value): static
*/
public function uid(int|string|array $uid): static
{
return $this->where(ImapSearchKey::Uid, implode(',', (array) $uid));
return $this->where(ImapSearchKey::Uid, new RawQueryValue(
Str::set(array_map('intval', (array) $uid))
));
}

/**
Expand Down
16 changes: 16 additions & 0 deletions tests/Unit/Connection/ImapQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,19 @@ function (ImapQueryBuilder $q) {

expect($builder->toImap())->toBe('FOO "Jou&AOk-"');
});

test('compiles UID condition without quotes', function () {
$builder = new ImapQueryBuilder;

$builder->uid(2);

expect($builder->toImap())->toBe('UID 2');
});

test('compiles multiple UID values without quotes', function () {
$builder = new ImapQueryBuilder;

$builder->uid([2, 3, 5]);

expect($builder->toImap())->toBe('UID 2,3,5');
});