test create user rejects duplicate email
This commit is contained in:
parent
ac461afcf0
commit
30b8cc2c74
1 changed files with 16 additions and 0 deletions
|
|
@ -58,4 +58,20 @@ class CreateUserTest extends TestCase
|
|||
$user = $userRepo->find(0);
|
||||
$this->assertTrue($user->isAdmin());
|
||||
}
|
||||
|
||||
public function test_throws_when_email_already_taken(): void
|
||||
{
|
||||
$userRepo = new FakeUserRepository();
|
||||
$useCase = new CreateUser($userRepo);
|
||||
$useCase->execute(new CreateUserRequest(
|
||||
email: 'test@test.com',
|
||||
));
|
||||
|
||||
$this->expectException(BadRequestException::class);
|
||||
$this->expectExceptionMessage('email already taken');
|
||||
|
||||
$useCase->execute(new CreateUserRequest(
|
||||
email: 'test@test.com',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue