test that use case throws error if non existant user id given
This commit is contained in:
parent
21da1a8991
commit
f0eb4cf5d5
2 changed files with 21 additions and 1 deletions
|
|
@ -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',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue