Skip to content

Commit

Permalink
feat: delete steps
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezcasas committed Dec 20, 2023
1 parent b14966a commit 1857308
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
final readonly class CreateVideoStepCommandHandler implements CommandHandler
{
public function __construct(private VideoStepCreator $creator) {}

public function __invoke(): void {}
}
2 changes: 2 additions & 0 deletions src/Mooc/Steps/Application/Create/VideoStepCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
final readonly class VideoStepCreator
{
public function __construct(private StepRepository $repository) {}

public function __invoke(): void {}
}
2 changes: 2 additions & 0 deletions src/Mooc/Steps/Domain/StepRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ interface StepRepository
public function save(Step $step): void;

public function search(StepId $id): ?Step;

public function delete(Step $step): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down

0 comments on commit 1857308

Please sign in to comment.