test that todays schedule only returns uncompleted nodes
This commit is contained in:
parent
8eeff2c4fe
commit
e04931ac08
2 changed files with 25 additions and 1 deletions
|
|
@ -27,7 +27,8 @@ class GetTodaysSchedule
|
||||||
return array_filter(
|
return array_filter(
|
||||||
$scheduledNodes,
|
$scheduledNodes,
|
||||||
function (ScheduledNode $node) use ($date) {
|
function (ScheduledNode $node) use ($date) {
|
||||||
return $node->getDate() <= $date;
|
return $node->getDate() <= $date
|
||||||
|
&& $node->getCompleted() === false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,4 +87,27 @@ class GetTodaysScheduleTest extends TestCase
|
||||||
));
|
));
|
||||||
$this->assertEquals(2, count($result));
|
$this->assertEquals(2, count($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_only_returns_uncompleted_nodes(): void
|
||||||
|
{
|
||||||
|
$node = $this->scheduledNodeRepo->create(
|
||||||
|
new CreateScheduledNodeDto(
|
||||||
|
date: new DateTimeImmutable('2025-01-01'),
|
||||||
|
plan: $this->planRepo->find(0),
|
||||||
|
node: new Node(
|
||||||
|
id: 0,
|
||||||
|
title: 'test node',
|
||||||
|
text: new Text(id: 0, name: 'test text'),
|
||||||
|
parentNode: null,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$node->setCompleted(true);
|
||||||
|
$this->scheduledNodeRepo->update($node);
|
||||||
|
|
||||||
|
$result = $this->useCase->execute(new GetTodaysScheduleRequest(
|
||||||
|
date: '2025-01-02',
|
||||||
|
userId: 0,
|
||||||
|
));
|
||||||
|
$this->assertEquals(1, count($result));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue