You are here

public function CharactersTest::testCharacters in Password Policy 8.3

Tests the four character types and minimum character count per type.

@dataProvider charactersDataProvider

File

password_policy_characters/tests/src/Unit/CharactersTest.php, line 19

Class

CharactersTest
Tests the characters constraint.

Namespace

Drupal\Tests\password_policy_characters\Unit

Code

public function testCharacters($count, $type, $password, $result) {
  $characters = $this
    ->getMockBuilder('Drupal\\password_policy_characters\\Plugin\\PasswordConstraint\\PasswordCharacter')
    ->disableOriginalConstructor()
    ->setMethods([
    'getConfiguration',
    'formatPlural',
  ])
    ->getMock();
  $characters
    ->method('getConfiguration')
    ->willReturn([
    'character_count' => $count,
    'character_type' => $type,
  ]);
  $user = $this
    ->getMockBuilder('Drupal\\user\\Entity\\User')
    ->disableOriginalConstructor()
    ->getMock();
  $this
    ->assertEquals($characters
    ->validate($password, $user)
    ->isValid(), $result);
}