'' =>
['Invalid empty username', 'assertNotNull'
],
'foo/' =>
['Invalid username containing invalid chars', 'assertNotNull'
],
// NULL.
'foo' .
chr(0
) . 'bar' =>
['Invalid username containing chr(0)', 'assertNotNull'
],
// CR.
'foo' .
chr(13
) . 'bar' =>
['Invalid username containing chr(13)', 'assertNotNull'
],
str_repeat('x', UserInterface::USERNAME_MAX_LENGTH + 1
) =>
['Invalid excessively long username', 'assertNotNull'
],
];
// cSpell:enable
foreach ($test_cases as $name =>
$test_case) { [$description,
$test] =
$test_case;
$result =
user_validate_name($name);
$this->
$test($result,
$description . ' (' .
$name . ')'
);
} } /**
* Runs entity validation checks.
*/
public function testValidation() { $user = User::
create([ 'name' => 'test',
'mail' => 'test@example.com',
]);