function FilterPermissionUiTest::testHandlerUI

Same name in other branches
  1. 9 core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php \Drupal\Tests\user\Functional\Views\FilterPermissionUiTest::testHandlerUI()
  2. 8.9.x core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php \Drupal\Tests\user\Functional\Views\FilterPermissionUiTest::testHandlerUI()
  3. 10 core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php \Drupal\Tests\user\Functional\Views\FilterPermissionUiTest::testHandlerUI()

Tests basic filter handler settings in the UI.

File

core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php, line 46

Class

FilterPermissionUiTest
Tests the permission field handler ui.

Namespace

Drupal\Tests\user\Functional\Views

Code

public function testHandlerUI() : void {
    $this->drupalLogin($this->drupalCreateUser([
        'administer views',
        'administer users',
    ]));
    $this->drupalGet('admin/structure/views/view/test_filter_permission/edit/default');
    // Verify that the handler summary is correctly displaying the selected
    // permission.
    $this->assertSession()
        ->linkExists('User: Permission (= View user information)');
    $this->submitForm([], 'Save');
    // Verify that we can save the view.
    $this->assertSession()
        ->pageTextNotContains('No valid values found on filter: User: Permission.');
    $this->assertSession()
        ->pageTextContains('The view test_filter_permission has been saved.');
    // Verify that the handler summary is also correct when multiple values are
    // selected in the filter.
    $edit = [
        'options[value][]' => [
            'access user profiles',
            'administer views',
        ],
    ];
    $this->drupalGet('admin/structure/views/nojs/handler/test_filter_permission/default/filter/permission');
    $this->submitForm($edit, 'Apply');
    $this->assertSession()
        ->linkExists('User: Permission (or View us…)');
    $this->submitForm([], 'Save');
    // Verify that we can save the view.
    $this->assertSession()
        ->pageTextNotContains('No valid values found on filter: User: Permission.');
    $this->assertSession()
        ->pageTextContains('The view test_filter_permission has been saved.');
}

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