diff --git a/src/Mooc/Steps/Application/Create/CreateVideoStepCommandHandler.php b/src/Mooc/Steps/Application/Create/CreateVideoStepCommandHandler.php index 06e08645..34c30189 100644 --- a/src/Mooc/Steps/Application/Create/CreateVideoStepCommandHandler.php +++ b/src/Mooc/Steps/Application/Create/CreateVideoStepCommandHandler.php @@ -9,4 +9,6 @@ final readonly class CreateVideoStepCommandHandler implements CommandHandler { public function __construct(private VideoStepCreator $creator) {} + + public function __invoke(): void {} } diff --git a/src/Mooc/Steps/Application/Create/VideoStepCreator.php b/src/Mooc/Steps/Application/Create/VideoStepCreator.php index 806b1d4d..00a95230 100644 --- a/src/Mooc/Steps/Application/Create/VideoStepCreator.php +++ b/src/Mooc/Steps/Application/Create/VideoStepCreator.php @@ -9,4 +9,6 @@ final readonly class VideoStepCreator { public function __construct(private StepRepository $repository) {} + + public function __invoke(): void {} } diff --git a/src/Mooc/Steps/Domain/StepRepository.php b/src/Mooc/Steps/Domain/StepRepository.php index e6fa8b5c..031958b4 100644 --- a/src/Mooc/Steps/Domain/StepRepository.php +++ b/src/Mooc/Steps/Domain/StepRepository.php @@ -9,4 +9,6 @@ interface StepRepository public function save(Step $step): void; public function search(StepId $id): ?Step; + + public function delete(Step $step): void; } diff --git a/src/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepository.php b/src/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepository.php index 349ebb57..45a1151d 100644 --- a/src/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepository.php +++ b/src/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepository.php @@ -20,4 +20,9 @@ public function search(StepId $id): ?Step { return $this->repository(Step::class)->find($id); } + + public function delete(Step $step): void + { + $this->remove($step); + } } diff --git a/tests/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepositoryTest.php b/tests/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepositoryTest.php index 04037e41..f0a12d7d 100644 --- a/tests/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepositoryTest.php +++ b/tests/Mooc/Steps/Infrastructure/Persistence/MySqlStepRepositoryTest.php @@ -32,6 +32,18 @@ public function it_should_search_an_existing_step(Step $step): void $this->assertEquals($step, $this->repository()->search($step->id)); } + /** + * @test + * @dataProvider steps + */ + public function it_should_delete_an_existing_step(Step $step): void + { + $this->repository()->save($step); + $this->repository()->delete($step); + + $this->assertNull($this->repository()->search($step->id)); + } + public function steps(): array { return [