scheduled node repo with create method
This commit is contained in:
parent
5bb5bf0c47
commit
49328404c9
2 changed files with 37 additions and 0 deletions
8
app/ScheduledNode/ScheduledNodeRepository.php
Normal file
8
app/ScheduledNode/ScheduledNodeRepository.php
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\ScheduledNode;
|
||||
|
||||
interface ScheduledNodeRepository
|
||||
{
|
||||
public function create(CreateScheduledNodeDto $dto): ScheduledNode;
|
||||
}
|
||||
29
tests/Fakes/FakeScheduledNodeRepository.php
Normal file
29
tests/Fakes/FakeScheduledNodeRepository.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\ScheduledNode\CreateScheduledNodeDto;
|
||||
use App\ScheduledNode\ScheduledNode;
|
||||
use App\ScheduledNode\ScheduledNodeRepository;
|
||||
|
||||
class FakeScheduledNodeRepository implements ScheduledNodeRepository
|
||||
{
|
||||
private array $existingScheduledNodes = [];
|
||||
|
||||
public function create(CreateScheduledNodeDto $dto): ScheduledNode
|
||||
{
|
||||
$id = $this->nextId();
|
||||
$scheduledNode = new ScheduledNode(
|
||||
id: $id,
|
||||
date: $dto->date,
|
||||
);
|
||||
$this->existingScheduledNodes[$id] = $scheduledNode;
|
||||
|
||||
return $scheduledNode;
|
||||
}
|
||||
|
||||
public function nextId(): int
|
||||
{
|
||||
return count($this->existingScheduledNodes);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue