From 64edec514183ba8803d671242d33dc3e000d5749 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 24 Apr 2026 13:16:29 +0300 Subject: [PATCH] implement find by email in fake user repo --- tests/Fakes/FakeUserRepository.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Fakes/FakeUserRepository.php b/tests/Fakes/FakeUserRepository.php index cde7533..14c5cab 100644 --- a/tests/Fakes/FakeUserRepository.php +++ b/tests/Fakes/FakeUserRepository.php @@ -5,6 +5,7 @@ namespace Tests\Fakes; use App\User\UseCases\CreateUserDto; use App\User\User; use App\User\UserRepository; +use App\ValueObjects\EmailAddress; class FakeUserRepository implements UserRepository { @@ -32,6 +33,25 @@ class FakeUserRepository implements UserRepository ); } + public function findByEmail(EmailAddress $email): ?User + { + $user = array_find( + $this->existingUsers, + function (User $user) use ($email) { + return (string) $user->getEmail() === (string) $email; + } + ); + if ($user === null) { + return null; + } + + return new User( + id: $user->getId(), + email: $user->getEmail(), + isAdmin: $user->isAdmin(), + ); + } + public function create(CreateUserDto $dto): User { $id = $this->nextId();