Skip to content

Commit

Permalink
Dropped symfony 4 support in favor of symfony 6
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDC committed Oct 27, 2023
1 parent bba1223 commit a49fc55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
}
],
"require": {
"symfony/validator": "^4|^5",
"symfony/security-core": "^4|^5"
"symfony/validator": "^5|^6",
"symfony/security-core": "^5|^6"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Constraints/PasswordValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function validate($value, Constraint $constraint)
->addViolation();
}

if ($value instanceof UserInterface && false !== strpos($stringValue, $value->getUserName())) {
if ($value instanceof UserInterface && false !== strpos($stringValue, $value->getUserIdentifier())) {
$this->context
->buildViolation($constraint->usernameMessage)
->setInvalidValue($value)
Expand Down
17 changes: 9 additions & 8 deletions tests/src/Constraints/ClassConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use PasswordValidator\Constraints\Password;
use PasswordValidator\Constraints\PasswordValidator;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Validator\Exception\MissingOptionsException;

class PasswordValidatorTest extends \Symfony\Component\Validator\Test\ConstraintValidatorTestCase
{
public function testNotEqualsUserName()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', '[email protected]');
$user = new InMemoryUser('[email protected]', '[email protected]');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -21,7 +22,7 @@ public function testNotEqualsUserName()

public function testNotContainsUserName()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', '[email protected]');
$user = new InMemoryUser('[email protected]', '[email protected]');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -32,7 +33,7 @@ public function testNotContainsUserName()

public function testLength()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', 'Foo1');
$user = new InMemoryUser('[email protected]', 'Foo1');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -43,7 +44,7 @@ public function testLength()

public function testNumber()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', '[email protected]');
$user = new InMemoryUser('[email protected]', '[email protected]');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -54,7 +55,7 @@ public function testNumber()

public function testUpperCase()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', '[email protected]');
$user = new InMemoryUser('[email protected]', '[email protected]');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -65,7 +66,7 @@ public function testUpperCase()

public function testLowerCase()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', 'FOOBARBAZ1');
$user = new InMemoryUser('[email protected]', 'FOOBARBAZ1');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -76,7 +77,7 @@ public function testLowerCase()

public function testProperPassword()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', '[email protected]');
$user = new InMemoryUser('[email protected]', '[email protected]');
$passwordConstraint = new Password(['plainPasswordAccessor' => 'getPassword', 'plainPasswordProperty' => 'password']);

$this->validator->validate($user, $passwordConstraint);
Expand All @@ -86,7 +87,7 @@ public function testProperPassword()
// Check whether class and property options are mixed
public function testInvalidUserConfiguration()
{
$user = new Symfony\Component\Security\Core\User\User('[email protected]', '[email protected]');
$user = new InMemoryUser('[email protected]', '[email protected]');
$passwordConstraint = new Password();

$this->expectException(MissingOptionsException::class);
Expand Down

0 comments on commit a49fc55

Please sign in to comment.