From 6668240126dbe68eea507128f3e5e62bfbd92f4b Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 2 May 2026 21:27:45 +0300 Subject: [PATCH] update fake text repository for user include the user when rebuilding Text instances in find and getAll, preserving the rule that lookup methods return new instances rather than stored references. --- tests/Fakes/FakeTextRepository.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/Fakes/FakeTextRepository.php b/tests/Fakes/FakeTextRepository.php index 7dac270..3e556a2 100644 --- a/tests/Fakes/FakeTextRepository.php +++ b/tests/Fakes/FakeTextRepository.php @@ -19,6 +19,7 @@ class FakeTextRepository implements TextRepository $text = new Text( id: $id, name: $dto->name, + user: $dto->user, ); $this->existingTexts[$id] = $text; @@ -27,19 +28,15 @@ class FakeTextRepository implements TextRepository public function find(int $id): ?Text { - $text = array_find( - $this->existingTexts, - function (Text $text) use ($id) { - return $text->getId() === $id; - } - ); - if ($text === null) { + if (!isset($this->existingTexts[$id])) { return null; } + $text = $this->existingTexts[$id]; return new Text( - id: $id, + id: $text->getId(), name: $text->getName(), + user: $text->getUser(), ); } @@ -58,9 +55,10 @@ class FakeTextRepository implements TextRepository return new Text( id: $text->getId(), name: $text->getName(), + user: $text->getUser(), ); }, - $this->existingTexts + array_values($this->existingTexts) ); } }