test that all nodes up until given date are returned
This commit is contained in:
parent
2047cd72e7
commit
ec4dca87a6
2 changed files with 22 additions and 4 deletions
|
|
@ -27,8 +27,7 @@ class GetTodaysSchedule
|
|||
return array_filter(
|
||||
$scheduledNodes,
|
||||
function (ScheduledNode $node) use ($date) {
|
||||
return $node->getDate()->format('Y-m-d')
|
||||
=== $date->format('Y-m-d');
|
||||
return $node->getDate() <= $date;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class GetTodaysScheduleTest extends TestCase
|
|||
user: $user,
|
||||
));
|
||||
$this->scheduledNodeRepo->create(new CreateScheduledNodeDto(
|
||||
date: new DateTimeImmutable('2025-01-01'),
|
||||
date: new DateTimeImmutable('2025-01-02'),
|
||||
plan: $plan,
|
||||
node: new Node(
|
||||
id: 0,
|
||||
|
|
@ -61,11 +61,30 @@ class GetTodaysScheduleTest extends TestCase
|
|||
public function test_returns_array_of_scheduled_nodes(): void
|
||||
{
|
||||
$result = $this->useCase->execute(new GetTodaysScheduleRequest(
|
||||
date: '2025-01-01',
|
||||
date: '2025-01-02',
|
||||
userId: 0,
|
||||
));
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertInstanceOf(ScheduledNode::class, $result[0]);
|
||||
}
|
||||
|
||||
public function test_returns_all_unfinished_scheduled_nodes_up_until_today(): void
|
||||
{
|
||||
$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,
|
||||
),
|
||||
));
|
||||
$result = $this->useCase->execute(new GetTodaysScheduleRequest(
|
||||
date: '2025-01-02',
|
||||
userId: 0,
|
||||
));
|
||||
$this->assertEquals(2, count($result));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue