plan repo with create method
This commit is contained in:
parent
957de13e71
commit
de744c9b15
3 changed files with 47 additions and 0 deletions
29
tests/Fakes/FakePlanRepository.php
Normal file
29
tests/Fakes/FakePlanRepository.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Plan\CreatePlanDto;
|
||||
use App\Plan\Plan;
|
||||
use App\Plan\PlanRepository;
|
||||
|
||||
class FakePlanRepository implements PlanRepository
|
||||
{
|
||||
private array $existingPlans = [];
|
||||
|
||||
public function create(CreatePlanDto $dto): Plan
|
||||
{
|
||||
$id = $this->nextId();
|
||||
$plan = new Plan(
|
||||
id: $id,
|
||||
name: $dto->name,
|
||||
);
|
||||
$this->existingPlans[$id] = $plan;
|
||||
|
||||
return $plan;
|
||||
}
|
||||
|
||||
private function nextId(): int
|
||||
{
|
||||
return count($this->existingPlans);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue