planRepo = new FakePlanRepository; $this->userRepo = new FakeUserRepository; $this->userRepo->create(new CreateUserDto( email: new EmailAddress('test@test.com'), )); $this->useCase = new CreatePlan( $this->planRepo, $this->userRepo, ); } public function test_create_plan(): void { $plan = $this->useCase->execute(new CreatePlanRequest( userId: 0, name: 'testPlan', )); $this->assertEquals('testPlan', $plan->getName()); } public function test_plan_has_user(): void { $plan = $this->useCase->execute(new CreatePlanRequest( userId: 0, name: 'testPlan', )); $this->assertInstanceOf(User::class, $plan->getUser()); } public function test_nonexistant_user_id_throws(): void { $this->expectException(DomainException::class); $this->expectExceptionMessage("User with id: 1 doesnt exist"); $plan = $this->useCase->execute(new CreatePlanRequest( userId: 1, name: 'testPlan', )); } }