From 7fb0adbea6c6979dc78514ad53d65960f4f1f969 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 8 Aug 2026 22:26:53 +0300 Subject: [PATCH] stabilize auth endpoint tests --- backend/tests/Feature/Auth/LogoutEndpointTest.php | 3 +++ backend/tests/Feature/Auth/MeEndpointTest.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/backend/tests/Feature/Auth/LogoutEndpointTest.php b/backend/tests/Feature/Auth/LogoutEndpointTest.php index 3986cb9..b593664 100644 --- a/backend/tests/Feature/Auth/LogoutEndpointTest.php +++ b/backend/tests/Feature/Auth/LogoutEndpointTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\Auth; use App\Auth\CreateSessionDto; +use App\Auth\Clock; use App\Auth\SessionRepository; use App\Http\Middleware\AuthMiddleware; use App\Shared\ValueObject\EmailAddress; @@ -11,6 +12,7 @@ use App\User\UserRepository; use DateTimeImmutable; use DateTimeZone; use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\Fakes\FakeClock; use Tests\TestCase; class LogoutEndpointTest extends TestCase @@ -23,6 +25,7 @@ class LogoutEndpointTest extends TestCase '2026-07-31T12:00:00', new DateTimeZone('UTC'), ); + $this->app->instance(Clock::class, new FakeClock($now)); $user = app(UserRepository::class)->create(new CreateUserDto( email: new EmailAddress('user@example.com'), passwordHash: 'hashed-password', diff --git a/backend/tests/Feature/Auth/MeEndpointTest.php b/backend/tests/Feature/Auth/MeEndpointTest.php index 3cabaf1..e776adb 100644 --- a/backend/tests/Feature/Auth/MeEndpointTest.php +++ b/backend/tests/Feature/Auth/MeEndpointTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\Auth; use App\Auth\CreateSessionDto; +use App\Auth\Clock; use App\Auth\SessionRepository; use App\Http\Middleware\AuthMiddleware; use App\Shared\ValueObject\EmailAddress; @@ -11,6 +12,7 @@ use App\User\UserRepository; use DateTimeImmutable; use DateTimeZone; use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\Fakes\FakeClock; use Tests\TestCase; class MeEndpointTest extends TestCase @@ -23,6 +25,7 @@ class MeEndpointTest extends TestCase '2026-07-31T12:00:00', new DateTimeZone('UTC'), ); + $this->app->instance(Clock::class, new FakeClock($now)); $user = app(UserRepository::class)->create(new CreateUserDto( email: new EmailAddress('user@example.com'), passwordHash: 'hashed-password',