From 66c49e07dd35a56c54d09d8e7e1890078530de87 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Mon, 23 Feb 2026 10:45:50 +0200 Subject: [PATCH] refactor to set up method --- tests/Unit/Plan/UseCases/CreatePlanTest.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/Unit/Plan/UseCases/CreatePlanTest.php b/tests/Unit/Plan/UseCases/CreatePlanTest.php index 095a64c..ce2c48e 100644 --- a/tests/Unit/Plan/UseCases/CreatePlanTest.php +++ b/tests/Unit/Plan/UseCases/CreatePlanTest.php @@ -9,11 +9,18 @@ use PHPUnit\Framework\TestCase; class CreatePlanTest extends TestCase { + private FakePlanRepository $planRepo; + private CreatePlan $useCase; + + public function setUp(): void + { + $this->planRepo = new FakePlanRepository; + $this->useCase = new CreatePlan($this->planRepo); + } + public function test_create_plan(): void { - $planRepo = new FakePlanRepository; - $useCase = new CreatePlan($planRepo); - $plan = $useCase->execute(new CreatePlanRequest( + $plan = $this->useCase->execute(new CreatePlanRequest( name: 'testPlan', )); $this->assertEquals('testPlan', $plan->getName());