Skip to content

Commit

Permalink
update validation messages in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley committed Mar 25, 2024
1 parent f86a788 commit 3e15008
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions tests/Fortify/Actions/CreateNewUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
'password' => $this->validPassword,
'password_confirmation' => $this->validPassword,
'terms' => true,
]), 'email', 'The email must be a valid email address.');
]), 'email', 'The email field must be a valid email address.');
});

it('should require the terms to be accepted', function () {
Expand All @@ -132,7 +132,7 @@
'password' => $this->validPassword,
'password_confirmation' => $this->validPassword,
'terms' => false,
]), 'terms', 'The terms must be accepted.');
]), 'terms', 'The terms field must be accepted.');
});

it('password should match the confirmation', function () {
Expand All @@ -145,7 +145,7 @@
'password' => $this->validPassword,
'password_confirmation' => 'password',
'terms' => true,
]), 'password_confirmation', 'The password confirmation and password must match.');
]), 'password_confirmation', 'The password confirmation field must match password.');
});

it('password should be equal to or longer than 12 characters', function () {
Expand All @@ -158,7 +158,7 @@
'password' => 'Sec$r2t',
'password_confirmation' => 'Sec$r2t',
'terms' => true,
]), 'password', 'The password must be at least 12 characters.');
]), 'password', 'The password field must be at least 12 characters.');
});

it('password should require an uppercase letter', function () {
Expand All @@ -171,7 +171,7 @@
'password' => 'sec$r2t12345',
'password_confirmation' => 'sec$r2t12345',
'terms' => true,
]), 'password', 'The password must contain at least one uppercase and one lowercase letter.');
]), 'password', 'The password field must contain at least one uppercase and one lowercase letter.');
});

it('password should require one number', function () {
Expand All @@ -184,7 +184,7 @@
'password' => 'sec$%Asfhhdfhfdhgd',
'password_confirmation' => 'sec$%Asfhhdfhfdhgd',
'terms' => true,
]), 'password', 'The password must contain at least one number.');
]), 'password', 'The password field must contain at least one number.');
});

it('password should require one special character', function () {
Expand All @@ -197,7 +197,7 @@
'password' => 'sec23Asfhhdfhfdhgd',
'password_confirmation' => 'sec23Asfhhdfhfdhgd',
'terms' => true,
]), 'password', 'The password must contain at least one symbol.');
]), 'password', 'The password field must contain at least one symbol.');
});

it('handles the invitation parameter', function () {
Expand Down Expand Up @@ -308,5 +308,5 @@
'password' => $this->validPassword,
'password_confirmation' => $this->validPassword,
'terms' => true,
]))->toThrow('The email must be a valid email address.');
]))->toThrow('The email field must be a valid email address.');
});
8 changes: 4 additions & 4 deletions tests/Fortify/Actions/ResetUserPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

expectValidationError(fn () => resolve(ResetUserPassword::class)->reset($user, [
'password' => 'pass',
]), 'password', 'The password must be at least 12 characters.');
]), 'password', 'The password field must be at least 12 characters.');
});

it('should throw an exception if the password is too weak', function () {
$user = createUserModel();

expectValidationError(fn () => resolve(ResetUserPassword::class)->reset($user, [
'password' => 'weak',
]), 'password', 'The password must be at least 12 characters.');
]), 'password', 'The password field must be at least 12 characters.');
});

it('should throw an exception if the password is not confirmed', function () {
Expand All @@ -47,7 +47,7 @@
expectValidationError(fn () => resolve(ResetUserPassword::class)->reset($user, [
'password' => 'Pas3w05d&123456',
'password_confirmation' => null,
]), 'password_confirmation', 'The password confirmation and password must match.');
]), 'password_confirmation', 'The password confirmation field must match password.');
});

it('should throw an exception if the password confirmation does not match', function () {
Expand All @@ -56,7 +56,7 @@
expectValidationError(fn () => resolve(ResetUserPassword::class)->reset($user, [
'password' => 'Pas3w05d&123456',
'password_confirmation' => 'password',
]), 'password_confirmation', 'The password confirmation and password must match.');
]), 'password_confirmation', 'The password confirmation field must match password.');
});

it('should throw an exception if the password is the same', function () {
Expand Down
8 changes: 4 additions & 4 deletions tests/Fortify/Actions/UpdateUserPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'current_password' => 'password',
'password' => 'Pas3w05d&',
'password_confirmation' => 'Pas3w05d&',
]), 'password', 'The password must be at least 12 characters.');
]), 'password', 'The password field must be at least 12 characters.');
});

it('should throw an exception if the new password is too weak', function () {
Expand All @@ -51,7 +51,7 @@
expectValidationError(fn () => resolve(UpdateUserPassword::class)->update($user, [
'current_password' => 'password',
'password' => 'weak',
]), 'password', 'The password must be at least 12 characters.');
]), 'password', 'The password field must be at least 12 characters.');
});

it('should throw an exception if the new password is not confirmed', function () {
Expand All @@ -61,7 +61,7 @@
'current_password' => 'password',
'password' => 'Pas3w05d&123456',
'password_confirmation' => null,
]), 'password_confirmation', 'The password confirmation and password must match.');
]), 'password_confirmation', 'The password confirmation field must match password.');
});

it('should throw an exception if the new password confirmation does not match', function () {
Expand All @@ -71,5 +71,5 @@
'current_password' => 'password',
'password' => 'Pas3w05d&123456',
'password_confirmation' => 'password',
]), 'password_confirmation', 'The password confirmation and password must match.');
]), 'password_confirmation', 'The password confirmation field must match password.');
});
8 changes: 4 additions & 4 deletions tests/Fortify/Actions/UpdateUserProfileInformationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
expectValidationError(fn () => resolve(UpdateUserProfileInformation::class)->update($user, [
'name' => str_repeat('a', 2),
'email' => '[email protected]',
]), 'name', 'The name must be at least 3 characters.');
]), 'name', 'The name field must be at least 3 characters.');
});

it('should throw an exception if the name is too long', function () {
Expand All @@ -96,7 +96,7 @@
expectValidationError(fn () => resolve(UpdateUserProfileInformation::class)->update($user, [
'name' => 'a'.str_repeat('a', 31),
'email' => '[email protected]',
]), 'name', 'The name must not be greater than 30 characters.');
]), 'name', 'The name field must not be greater than 30 characters.');
});

it('should throw an exception if the email is missing', function () {
Expand All @@ -114,7 +114,7 @@
expectValidationError(fn () => resolve(UpdateUserProfileInformation::class)->update($user, [
'name' => 'Jane Doe',
'email' => str_repeat('#', 256).'@doe.com',
]), 'email', 'The email must not be greater than 255 characters.');
]), 'email', 'The email field must not be greater than 255 characters.');
});

it('should throw an exception if the email is not an email', function () {
Expand All @@ -123,5 +123,5 @@
expectValidationError(fn () => resolve(UpdateUserProfileInformation::class)->update($user, [
'name' => 'Jane Doe',
'email' => str_repeat('#', 256),
]), 'email', 'The email must be a valid email address.');
]), 'email', 'The email field must be a valid email address.');
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
$response = $response->toResponse($request);

expect($response->getStatusCode())->toBe(200);
expect($response->getData('message'))->toBe(['message' => 'We have emailed your password reset link!']);
expect($response->getData('message'))->toBe(['message' => 'We have emailed your password reset link.']);
});

0 comments on commit 3e15008

Please sign in to comment.