test that only nodes which are not parents are scheduled
This commit is contained in:
parent
bd2679f258
commit
844813499a
2 changed files with 33 additions and 0 deletions
|
|
@ -10,8 +10,11 @@ class FakeScheduledNodeRepository implements ScheduledNodeRepository
|
||||||
{
|
{
|
||||||
private array $existingScheduledNodes = [];
|
private array $existingScheduledNodes = [];
|
||||||
|
|
||||||
|
private int $numberOfTimesCreateCalled = 0;
|
||||||
|
|
||||||
public function create(CreateScheduledNodeDto $dto): ScheduledNode
|
public function create(CreateScheduledNodeDto $dto): ScheduledNode
|
||||||
{
|
{
|
||||||
|
$this->numberOfTimesCreateCalled++;
|
||||||
$id = $this->nextId();
|
$id = $this->nextId();
|
||||||
$scheduledNode = new ScheduledNode(
|
$scheduledNode = new ScheduledNode(
|
||||||
id: $id,
|
id: $id,
|
||||||
|
|
@ -33,6 +36,11 @@ class FakeScheduledNodeRepository implements ScheduledNodeRepository
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNumberOfTimesCreateCalled(): int
|
||||||
|
{
|
||||||
|
return $this->numberOfTimesCreateCalled;
|
||||||
|
}
|
||||||
|
|
||||||
private function nextId(): int
|
private function nextId(): int
|
||||||
{
|
{
|
||||||
return count($this->existingScheduledNodes);
|
return count($this->existingScheduledNodes);
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,29 @@ class CreatePlanTest extends TestCase
|
||||||
));
|
));
|
||||||
$this->assertNotNull($this->scheduledNodeRepo->find(0));
|
$this->assertNotNull($this->scheduledNodeRepo->find(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_plan_only_schedules_nodes_which_arent_parents(): void
|
||||||
|
{
|
||||||
|
$text = $this->textRepo->create(new CreateTextDto(
|
||||||
|
name: 'testname',
|
||||||
|
));
|
||||||
|
$rootNode = $this->nodeRepo->create(new CreateNodeDto(
|
||||||
|
text: $text,
|
||||||
|
title: 'root node',
|
||||||
|
parentNode: null,
|
||||||
|
));
|
||||||
|
$this->nodeRepo->create(new CreateNodeDto(
|
||||||
|
text: $text,
|
||||||
|
title: 'child node',
|
||||||
|
parentNode: $rootNode,
|
||||||
|
));
|
||||||
|
$plan = $this->useCase->execute(new CreatePlanRequest(
|
||||||
|
userId: 0,
|
||||||
|
name: 'testPlan',
|
||||||
|
textId: 0,
|
||||||
|
));
|
||||||
|
$this->assertEquals(
|
||||||
|
1, $this->scheduledNodeRepo->getNumberOfTimesCreateCalled()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue