refactor to set up method

This commit is contained in:
Yisroel Baum 2026-02-23 10:45:50 +02:00
parent 9f29b9b94e
commit 66c49e07dd
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -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());