-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4789b83
commit 993f6f5
Showing
11 changed files
with
541 additions
and
479 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ public function submitSymfonyForm(FunctionalTester $I) | |
$I->amOnPage('/register'); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$I->seeInRepository(User::class, [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ public function seeOrphanEvent(FunctionalTester $I) | |
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true, | ||
]); | ||
$I->seeOrphanEvent(UserRegisteredEvent::class); | ||
|
@@ -96,7 +96,7 @@ public function seeEvent(FunctionalTester $I) | |
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true, | ||
]); | ||
$I->seeEvent(UserRegisteredEvent::class); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ public function dontSeeFormErrors(FunctionalTester $I) | |
$I->amOnPage('/register'); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$I->dontSeeFormErrors(); | ||
|
@@ -24,7 +24,7 @@ public function seeFormErrorMessage(FunctionalTester $I) | |
$I->amOnPage('/register'); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$I->seeFormErrorMessage('email'); | ||
|
@@ -36,19 +36,19 @@ public function seeFormErrorMessages(FunctionalTester $I) | |
$I->amOnPage('/register'); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123', | ||
'[password]' => '123', | ||
'[agreeTerms]' => true | ||
]); | ||
|
||
// Only with the names of the fields | ||
$I->seeFormErrorMessages(['email', 'plainPassword']); | ||
$I->seeFormErrorMessages(['email', 'password']); | ||
|
||
// With field names and error messages | ||
$I->seeFormErrorMessages([ | ||
// Full Message | ||
'email' => 'There is already an account with this email', | ||
// Part of a message | ||
'plainPassword' => 'at least 6 characters' | ||
'password' => 'at least 6 characters' | ||
]); | ||
} | ||
|
||
|
@@ -57,10 +57,10 @@ public function seeFormHasErrors(FunctionalTester $I) | |
$I->amOnPage('/register'); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
//There is already an account with this email | ||
// There is already an account with this email | ||
$I->seeFormHasErrors(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ public function dontSeeEmailIsSent(FunctionalTester $I) | |
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
//There is already an account with this email | ||
|
@@ -27,7 +27,7 @@ public function grabLastSentEmail(FunctionalTester $I) | |
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$email = $I->grabLastSentEmail(); | ||
|
@@ -41,7 +41,7 @@ public function grabSentEmails(FunctionalTester $I) | |
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$emails = $I->grabSentEmails(); | ||
|
@@ -55,7 +55,7 @@ public function seeEmailIsSent(FunctionalTester $I) | |
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[password]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$I->seeEmailIsSent(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Functional; | ||
|
||
use App\Entity\User; | ||
use App\Tests\Support\FunctionalTester; | ||
use Symfony\Component\Validator\Constraints\Email; | ||
use Symfony\Component\Validator\Constraints\Length; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
|
||
final class ValidatorCest | ||
{ | ||
public function dontSeeViolatedConstraint(FunctionalTester $I) | ||
{ | ||
$user = User::create('[email protected]', 'password', ['ROLE_ADMIN']); | ||
$I->dontSeeViolatedConstraint($user); | ||
$I->dontSeeViolatedConstraint($user, 'email'); | ||
$I->dontSeeViolatedConstraint($user, 'email', Email::class); | ||
|
||
$user->setEmail('invalid_email'); | ||
$I->dontSeeViolatedConstraint($user, 'password'); | ||
|
||
$user->setEmail('[email protected]'); | ||
$user->setPassword('weak'); | ||
$I->dontSeeViolatedConstraint($user, 'email'); | ||
$I->dontSeeViolatedConstraint($user, 'password', NotBlank::class); | ||
} | ||
|
||
public function seeViolatedConstraint(FunctionalTester $I) | ||
{ | ||
$user = User::create('invalid_email', 'password', ['ROLE_ADMIN']); | ||
$I->seeViolatedConstraint($user); | ||
$I->seeViolatedConstraint($user, 'email'); | ||
|
||
$user->setEmail('[email protected]'); | ||
$user->setPassword('weak'); | ||
$I->seeViolatedConstraint($user); | ||
$I->seeViolatedConstraint($user, 'password'); | ||
$I->seeViolatedConstraint($user, 'password', Length::class); | ||
} | ||
|
||
public function seeViolatedConstraintCount(FunctionalTester $I) | ||
{ | ||
$user = User::create('invalid_email', 'weak', ['ROLE_ADMIN']); | ||
$I->seeViolatedConstraintsCount(2, $user); | ||
$I->seeViolatedConstraintsCount(1, $user, 'email'); | ||
$user->setEmail('[email protected]'); | ||
$I->seeViolatedConstraintsCount(1, $user); | ||
$I->seeViolatedConstraintsCount(0, $user, 'email'); | ||
} | ||
|
||
public function seeViolatedConstraintMessageContains(FunctionalTester $I) | ||
{ | ||
$user = User::create('invalid_email', 'weak', ['ROLE_ADMIN']); | ||
$I->seeViolatedConstraintMessage('is not a valid email', $user, 'email'); | ||
$user->setEmail(''); | ||
$I->seeViolatedConstraintMessage('should not be blank', $user, 'email'); | ||
$I->seeViolatedConstraintMessage('This value is too short', $user, 'email'); | ||
} | ||
} |