scheduledNodeRepo = new FakeScheduledNodeRepository(); $this->planRepo = new FakePlanRepository(); $this->planRepo->create(new CreatePlanDto( name: 'testplan', user: new User(0, new EmailAddress('test@test.com')), )); $this->useCase = new CreateScheduledNode( $this->scheduledNodeRepo, $this->planRepo, ); } public function test_create_scheduled_node(): void { $scheduledNode = $this->useCase->execute( new CreateScheduledNodeRequest( date: '2025-01-01', planId: 0, ) ); $this->assertInstanceOf(ScheduledNode::class, $scheduledNode); $this->assertInstanceOf( ScheduledNodeRepository::class, $this->scheduledNodeRepo ); } public function test_scheduled_node_belongs_to_plan(): void { $scheduledNode = $this->useCase->execute( new CreateScheduledNodeRequest( date: '2025-01-01', planId: 0, ) ); $this->assertInstanceOf(Plan::class, $scheduledNode->getPlan()); } public function test_nonexistant_plan_throws(): void { $this->expectException(DomainException::class); $this->expectExceptionMessage('Plan with id: 1 doesnt exist'); $this->useCase->execute( new CreateScheduledNodeRequest( date: '2025-01-01', planId: 1, ) ); } public function test_throws_if_date_is_null(): void { $this->expectException(BadRequestException::class); $this->expectExceptionMessage('date is required'); $this->useCase->execute( new CreateScheduledNodeRequest( date: null, planId: 0, ) ); } public function test_throws_if_plan_id_is_null(): void { $this->expectException(BadRequestException::class); $this->expectExceptionMessage('planId is required'); $this->useCase->execute( new CreateScheduledNodeRequest( date: '2025-01-01', planId: null, ) ); } }