From 495523d5d5c4715d65ed2024d80a2fc50ccabc9a Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Wed, 15 Jul 2026 20:47:55 +0900 Subject: [PATCH 1/2] feat: add LogoutUseCase --- .../UseCase/User/LogoutUseCase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/app/Packages/Features/CommandUseCases/UseCase/User/LogoutUseCase.php diff --git a/src/app/Packages/Features/CommandUseCases/UseCase/User/LogoutUseCase.php b/src/app/Packages/Features/CommandUseCases/UseCase/User/LogoutUseCase.php new file mode 100644 index 0000000..432496b --- /dev/null +++ b/src/app/Packages/Features/CommandUseCases/UseCase/User/LogoutUseCase.php @@ -0,0 +1,17 @@ +tokenService->revokeCurrentToken($plainTextToken); + } +} From 4ccb5595d5d19831308a89efac779e2efaebc0ad Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Wed, 15 Jul 2026 20:47:57 +0900 Subject: [PATCH 2/2] test: add unit tests for LogoutUseCase --- .../CommandUseCases/LogoutUseCaseTest.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/app/Packages/Features/Tests/CommandUseCases/LogoutUseCaseTest.php diff --git a/src/app/Packages/Features/Tests/CommandUseCases/LogoutUseCaseTest.php b/src/app/Packages/Features/Tests/CommandUseCases/LogoutUseCaseTest.php new file mode 100644 index 0000000..ad1b7d9 --- /dev/null +++ b/src/app/Packages/Features/Tests/CommandUseCases/LogoutUseCaseTest.php @@ -0,0 +1,45 @@ +shouldReceive('revokeCurrentToken') + ->once() + ->with('plain-text-token'); + + (new LogoutUseCase($tokenService))->handle('plain-text-token'); + } + + public function test_handle_propagates_exception_when_revocation_fails(): void + { + /** @var TokenServiceInterface|MockInterface $tokenService */ + $tokenService = Mockery::mock(TokenServiceInterface::class); + $tokenService->shouldReceive('revokeCurrentToken') + ->once() + ->andThrow(new RuntimeException('Revocation failed.')); + + $this->expectException(RuntimeException::class); + $this->expectExceptionMessage('Revocation failed.'); + + (new LogoutUseCase($tokenService))->handle('plain-text-token'); + } +}