function UserNameValidatorTest::testInvalidUsernames

Same name in other branches
  1. 11.x core/modules/user/tests/src/Kernel/UserNameValidatorTest.php \Drupal\Tests\user\Kernel\UserNameValidatorTest::testInvalidUsernames()

Tests invalid user name validation.

@dataProvider invalidUserNameProvider

File

core/modules/user/tests/src/Kernel/UserNameValidatorTest.php, line 51

Class

UserNameValidatorTest
Verify that user validity checks behave as designed.

Namespace

Drupal\Tests\user\Kernel

Code

public function testInvalidUsernames($name, $expectedMessage) : void {
    $violations = $this->userValidator
        ->validateName($name);
    $this->assertNotEmpty($violations);
    $this->assertEquals($expectedMessage, $violations[0]->getMessage());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.