From 6b310c8c9c0d31603853b5581ca6ff9bf31443dc Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 24 Apr 2026 11:00:06 +0300 Subject: [PATCH] add plan controller test scaffold --- tests/e2e/Controllers/PlanControllerTest.php | 73 ++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/e2e/Controllers/PlanControllerTest.php diff --git a/tests/e2e/Controllers/PlanControllerTest.php b/tests/e2e/Controllers/PlanControllerTest.php new file mode 100644 index 0000000..50ddfe1 --- /dev/null +++ b/tests/e2e/Controllers/PlanControllerTest.php @@ -0,0 +1,73 @@ +planRepo = new FakePlanRepository(); + $this->userRepo = new FakeUserRepository(); + $this->textRepo = new FakeTextRepository(); + $this->nodeRepo = new FakeNodeRepository(); + $this->scheduledNodeRepo = new FakeScheduledNodeRepository(); + + $this->userRepo->create(new CreateUserDto( + email: new EmailAddress('test@test.com'), + )); + $text = $this->textRepo->create(new CreateTextDto('testname')); + $this->nodeRepo->create(new CreateNodeDto( + text: $text, + title: 'Root Node', + parentNode: null, + )); + + $createScheduledNode = new CreateScheduledNode( + scheduledNodeRepo: $this->scheduledNodeRepo, + planRepo: $this->planRepo, + ); + $this->createPlan = new CreatePlan( + $this->planRepo, + $this->userRepo, + $this->textRepo, + $this->nodeRepo, + $createScheduledNode, + ); + $this->controller = new PlanController(); + } + + private function makeRequest(array $data): ServerRequestInterface + { + $body = new StreamFactory()->createStream(json_encode($data)); + return new ServerRequestFactory() + ->createServerRequest('POST', 'http://localhost/api/plans') + ->withHeader('Content-Type', 'application/json') + ->withBody($body); + } +}