From baa5dee0b3443156806bcb48d09501f380ae653b Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Mon, 23 Feb 2026 10:57:56 +0200 Subject: [PATCH] test plan has user --- tests/Unit/Plan/UseCases/CreatePlanTest.php | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Plan/UseCases/CreatePlanTest.php b/tests/Unit/Plan/UseCases/CreatePlanTest.php index ce2c48e..c03b939 100644 --- a/tests/Unit/Plan/UseCases/CreatePlanTest.php +++ b/tests/Unit/Plan/UseCases/CreatePlanTest.php @@ -4,25 +4,48 @@ namespace Tests\Unit\Plan\UseCases; use App\Plan\UseCases\CreatePlan; use App\Plan\UseCases\CreatePlanRequest; +use App\User\UseCases\CreateUserDto; +use App\User\User; +use App\User\UserRepository; +use App\ValueObjects\EmailAddress; use Tests\Fakes\FakePlanRepository; use PHPUnit\Framework\TestCase; +use Tests\Fakes\FakeUserRepository; class CreatePlanTest extends TestCase { private FakePlanRepository $planRepo; + private UserRepository $userRepo; private CreatePlan $useCase; public function setUp(): void { $this->planRepo = new FakePlanRepository; - $this->useCase = new CreatePlan($this->planRepo); + $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()); + } }