UserPasswordValidator example

abstract class UserPasswordValidatorTestCase extends ConstraintValidatorTestCase
{
    private const PASSWORD = 's3Cr3t';
    private const SALT = '^S4lt$';

    protected TokenStorageInterface $tokenStorage;
    protected PasswordHasherInterface $hasher;
    protected PasswordHasherFactoryInterface $hasherFactory;

    protected function createValidator(): UserPasswordValidator
    {
        return new UserPasswordValidator($this->tokenStorage, $this->hasherFactory);
    }

    protected function setUp(): void
    {
        $user = $this->createUser();
        $this->tokenStorage = $this->createTokenStorage($user);
        $this->hasher = $this->createMock(PasswordHasherInterface::class);
        $this->hasherFactory = $this->createHasherFactory($this->hasher);

        parent::setUp();
    }

    
Home | Imprint | This part of the site doesn't use cookies.