From 1c6fd5047a1d0c369ccc1f140a8791b90e187c9d Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 14 Feb 2026 21:56:59 +0200 Subject: [PATCH] fake user repo --- tests/Fakes/FakeUserRepository.php | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/Fakes/FakeUserRepository.php diff --git a/tests/Fakes/FakeUserRepository.php b/tests/Fakes/FakeUserRepository.php new file mode 100644 index 0000000..2890de9 --- /dev/null +++ b/tests/Fakes/FakeUserRepository.php @@ -0,0 +1,45 @@ +existingUsers[$id]; + if ($user === null) { + return null; + } + + return new User( + id: $user->getId(), + email: $user->getEmail(), + ); + } + + public function create(CreateUserDto $dto): User + { + $id = $this->nextId(); + $user = new User( + id: $id, + email: $dto->email, + ); + $this->existingUsers[$id] = $user; + + return $user; + } + + private function nextId(): int + { + return count($this->existingUsers); + } +}