test that use case throws error if non existant user id given

This commit is contained in:
Yisroel Baum 2026-02-23 11:05:42 +02:00
parent 21da1a8991
commit f0eb4cf5d5
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 21 additions and 1 deletions

View file

@ -8,6 +8,7 @@ use App\User\UseCases\CreateUserDto;
use App\User\User;
use App\User\UserRepository;
use App\ValueObjects\EmailAddress;
use DomainException;
use Tests\Fakes\FakePlanRepository;
use PHPUnit\Framework\TestCase;
use Tests\Fakes\FakeUserRepository;
@ -48,4 +49,14 @@ class CreatePlanTest extends TestCase
));
$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',
));
}
}