function HandlerFilterUserNameTest::testAdminUserInterface

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php \Drupal\Tests\user\Functional\Views\HandlerFilterUserNameTest::testAdminUserInterface()
  2. 8.9.x core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php \Drupal\Tests\user\Functional\Views\HandlerFilterUserNameTest::testAdminUserInterface()
  3. 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 94

Class

HandlerFilterUserNameTest
Tests the handler of the user: name filter.

Namespace

Drupal\Tests\user\Functional\Views

Code

public function testAdminUserInterface() : void {
    $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) . '".');
}

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