test that only nodes which are not parents are scheduled

This commit is contained in:
Yisroel Baum 2026-03-21 20:00:14 +02:00
parent bd2679f258
commit 844813499a
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 33 additions and 0 deletions

View file

@ -10,8 +10,11 @@ class FakeScheduledNodeRepository implements ScheduledNodeRepository
{
private array $existingScheduledNodes = [];
private int $numberOfTimesCreateCalled = 0;
public function create(CreateScheduledNodeDto $dto): ScheduledNode
{
$this->numberOfTimesCreateCalled++;
$id = $this->nextId();
$scheduledNode = new ScheduledNode(
id: $id,
@ -33,6 +36,11 @@ class FakeScheduledNodeRepository implements ScheduledNodeRepository
);
}
public function getNumberOfTimesCreateCalled(): int
{
return $this->numberOfTimesCreateCalled;
}
private function nextId(): int
{
return count($this->existingScheduledNodes);

View file

@ -99,4 +99,29 @@ class CreatePlanTest extends TestCase
));
$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()
);
}
}