public function UserRestrictionsLoginTest::testUserRestrictionsCheckNameBlacklist in User restrictions 8
Ensure a user cannot log in if their name is on the blacklist.
File
- tests/
src/ Functional/ UserRestrictionsLoginTest.php, line 17
Class
- UserRestrictionsLoginTest
- Tests login restrictions.
Namespace
Drupal\Tests\user_restrictions\FunctionalCode
public function testUserRestrictionsCheckNameBlacklist() {
$this
->drupalGet('user/register');
$name = 'lol' . $this
->randomMachineName();
$edit = [];
$edit['name'] = $name;
$edit['mail'] = $this
->randomMachineName() . '@example.com';
$this
->drupalPostForm('user/register', $edit, t('Create new account'));
$text = (string) new FormattableMarkup('The name <em class="placeholder">@name</em> is reserved, and cannot be used.', [
'@name' => $name,
]);
$this
->assertRaw((string) $text, 'User "name" restricted.');
}