From 2eafe67f31eb23bbe893a3e3e0b2f762fa20e4b7 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 1 May 2026 10:19:03 +0300 Subject: [PATCH] test scope schedule to requesting user --- .../UseCases/GetTodaysScheduleTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Unit/ScheduledNode/UseCases/GetTodaysScheduleTest.php b/tests/Unit/ScheduledNode/UseCases/GetTodaysScheduleTest.php index f8a64b3..359b632 100644 --- a/tests/Unit/ScheduledNode/UseCases/GetTodaysScheduleTest.php +++ b/tests/Unit/ScheduledNode/UseCases/GetTodaysScheduleTest.php @@ -184,4 +184,39 @@ class GetTodaysScheduleTest extends TestCase $this->assertEquals(1, count($result)); } + + public function test_does_not_return_other_users_scheduled_nodes(): void + { + $otherUser = $this->userRepo->create(new CreateUserDto( + email: new EmailAddress('other@email.com'), + passwordHash: 'hash', + isAdmin: false, + )); + $otherPlan = $this->planRepo->create(new CreatePlanDto( + name: 'other plan', + user: $otherUser, + )); + $this->scheduledNodeRepo->create(new CreateScheduledNodeDto( + date: new DateTimeImmutable('2025-01-02'), + plan: $otherPlan, + node: new Node( + id: 0, + title: 'other 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(1, count($result)); + $resultNode = array_values($result)[0]; + $this->assertEquals( + 0, + $resultNode->getPlan()->getUser()->getId() + ); + } }