public function HandlerFilterUserNameTest::testAdminUserInterface in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php \Drupal\Tests\user\Functional\Views\HandlerFilterUserNameTest::testAdminUserInterface()
- 10 core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php \Drupal\Tests\user\Functional\Views\HandlerFilterUserNameTest::testAdminUserInterface()
Tests using the user interface.
File
- core/
modules/ user/ tests/ src/ Functional/ Views/ HandlerFilterUserNameTest.php, line 92
Class
- HandlerFilterUserNameTest
- Tests the handler of the user: name filter.
Namespace
Drupal\Tests\user\Functional\ViewsCode
public function testAdminUserInterface() {
$admin_user = $this
->drupalCreateUser([
'administer views',
'administer site configuration',
]);
$this
->drupalLogin($admin_user);
$path = 'admin/structure/views/nojs/handler/test_user_name/default/filter/uid';
$this
->drupalGet($path);
// Pass in an invalid username, the validation should catch it.
$users = [
$this
->randomMachineName(),
];
$users = array_map('strtolower', $users);
$edit = [
'options[value]' => implode(', ', $users),
];
$this
->drupalGet($path);
$this
->submitForm($edit, 'Apply');
$this
->assertSession()
->pageTextContains('There are no users matching "' . implode(', ', $users) . '".');
// Pass in an invalid username and a valid username.
$random_name = $this
->randomMachineName();
$users = [
$random_name,
$this->names[0],
];
$users = array_map('strtolower', $users);
$edit = [
'options[value]' => implode(', ', $users),
];
$users = [
$users[0],
];
$this
->drupalGet($path);
$this
->submitForm($edit, 'Apply');
$this
->assertSession()
->pageTextContains('There are no users matching "' . implode(', ', $users) . '".');
// Pass in just valid usernames.
$users = $this->names;
$users = array_map('strtolower', $users);
$edit = [
'options[value]' => implode(', ', $users),
];
$this
->drupalGet($path);
$this
->submitForm($edit, 'Apply');
$this
->assertSession()
->pageTextNotContains('There are no users matching "' . implode(', ', $users) . '".');
}