From 7ab91cc77d8372207c77bcff766f119c27296196 Mon Sep 17 00:00:00 2001 From: florentdevk Date: Wed, 1 Jul 2026 21:06:13 +0200 Subject: [PATCH] feat(application): add StartGame command, handler and GameRepository interface --- .../Command/StartGame/StartGameCommand.php | 9 +++++ .../Command/StartGame/StartGameHandler.php | 27 +++++++++++++ .../Repository/GameRepositoryInterface.php | 15 +++++++ .../StartGame/StartGameHandlerTest.php | 39 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 src/Chess/Application/Command/StartGame/StartGameCommand.php create mode 100644 src/Chess/Application/Command/StartGame/StartGameHandler.php create mode 100644 src/Chess/Domain/Repository/GameRepositoryInterface.php create mode 100644 tests/Chess/Application/Command/StartGame/StartGameHandlerTest.php diff --git a/src/Chess/Application/Command/StartGame/StartGameCommand.php b/src/Chess/Application/Command/StartGame/StartGameCommand.php new file mode 100644 index 0000000..3842b6d --- /dev/null +++ b/src/Chess/Application/Command/StartGame/StartGameCommand.php @@ -0,0 +1,9 @@ +repository->save($game); + + return $game->id(); + } +} diff --git a/src/Chess/Domain/Repository/GameRepositoryInterface.php b/src/Chess/Domain/Repository/GameRepositoryInterface.php new file mode 100644 index 0000000..aa2d099 --- /dev/null +++ b/src/Chess/Domain/Repository/GameRepositoryInterface.php @@ -0,0 +1,15 @@ +savedGame = $game; + } + + public function findById(GameId $id): ?Game + { + return null; + } + }; + + $handler = new StartGameHandler($repository); + $gameId = $handler(new StartGameCommand()); + + self::assertInstanceOf(GameId::class, $gameId); + self::assertNotNull($repository->savedGame); + self::assertSame($gameId->toString(), $repository->savedGame->id()->toString()); + } +}