public function PasswordLengthTest::testLength in Password Policy 8.3
Tests the password length.
@dataProvider lengthDataProvider
File
- password_policy_length/
tests/ src/ Unit/ PasswordLengthTest.php, line 19
Class
- PasswordLengthTest
- Tests the character length constraint.
Namespace
Drupal\Tests\password_policy_length\UnitCode
public function testLength($length, $operation, $password, $result) {
$characters = $this
->getMockBuilder('Drupal\\password_policy_length\\Plugin\\PasswordConstraint\\PasswordLength')
->disableOriginalConstructor()
->setMethods([
'getConfiguration',
'formatPlural',
])
->getMock();
$characters
->method('getConfiguration')
->willReturn([
'character_length' => $length,
'character_operation' => $operation,
]);
$user = $this
->getMockBuilder('Drupal\\user\\Entity\\User')
->disableOriginalConstructor()
->getMock();
$this
->assertEquals($characters
->validate($password, $user)
->isValid(), $result);
}