Skip to content

Commit 9cc5496

Browse files
committed
Make fake folder search case-insensitive
1 parent b5471bd commit 9cc5496

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Testing/FakeFolderRepository.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use DirectoryTree\ImapEngine\FolderRepositoryInterface;
88
use DirectoryTree\ImapEngine\MailboxInterface;
99
use DirectoryTree\ImapEngine\Support\Str;
10+
use Illuminate\Support\ItemNotFoundException;
1011

1112
class FakeFolderRepository implements FolderRepositoryInterface
1213
{
@@ -24,9 +25,11 @@ public function __construct(
2425
*/
2526
public function find(string $path): ?FolderInterface
2627
{
27-
return $this->get()->first(
28-
fn (FolderInterface $folder) => $folder->path() === $path
29-
);
28+
try {
29+
return $this->findOrFail($path);
30+
} catch (ItemNotFoundException) {
31+
return null;
32+
}
3033
}
3134

3235
/**
@@ -35,7 +38,7 @@ public function find(string $path): ?FolderInterface
3538
public function findOrFail(string $path): FolderInterface
3639
{
3740
return $this->get()->firstOrFail(
38-
fn (FolderInterface $folder) => $folder->path() === $path
41+
fn (FolderInterface $folder) => strtolower($folder->path()) === strtolower($path)
3942
);
4043
}
4144

0 commit comments

Comments
 (0)