diff --git a/backend/tests/Fakes/FakeTokenGenerator.php b/backend/tests/Fakes/FakeTokenGenerator.php index dcb8819..e10bbcf 100644 --- a/backend/tests/Fakes/FakeTokenGenerator.php +++ b/backend/tests/Fakes/FakeTokenGenerator.php @@ -3,11 +3,27 @@ namespace Tests\Fakes; use App\Auth\TokenGenerator; +use RuntimeException; class FakeTokenGenerator implements TokenGenerator { + private int $callCount = 0; + + /** + * @param string[] $tokens + */ + public function __construct(private array $tokens) {} + public function generate(): string { - return 'fake-token-123'; + if ($this->callCount >= count($this->tokens)) { + throw new RuntimeException( + 'FakeTokenGenerator exhausted' + ); + } + $token = $this->tokens[$this->callCount]; + $this->callCount++; + + return $token; } } diff --git a/backend/tests/Unit/Auth/UseCases/CreateSessionTest.php b/backend/tests/Unit/Auth/UseCases/CreateSessionTest.php index 0367f1c..034d7c5 100644 --- a/backend/tests/Unit/Auth/UseCases/CreateSessionTest.php +++ b/backend/tests/Unit/Auth/UseCases/CreateSessionTest.php @@ -22,7 +22,7 @@ class CreateSessionTest extends TestCase protected function setUp(): void { $this->sessionRepo = new FakeSessionRepository(); - $this->tokenGenerator = new FakeTokenGenerator(); + $this->tokenGenerator = new FakeTokenGenerator(['fake-token-123']); $this->clock = new FakeClock( new DateTimeImmutable('2026-05-18 12:00:00') );