function RolesRidArgumentTest::testArgumentTitle

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

Tests the generated title of a user: roles argument.

File

core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php, line 35

Class

RolesRidArgumentTest
Tests the handler of the user: roles argument.

Namespace

Drupal\Tests\user\Functional\Views

Code

public function testArgumentTitle() : void {
    $role_id = $this->createRole([], 'markup_role_name', '<em>Role name with markup</em>');
    $this->createRole([], 'second_role_name', 'Second role name');
    $user = $this->createUser([], 'User with role one');
    $user->addRole($role_id)
        ->save();
    $second_user = $this->createUser([], 'User with role two');
    $second_user->addRole('second_role_name')
        ->save();
    $this->drupalGet('/user_roles_rid_test/markup_role_name');
    $this->assertSession()
        ->assertEscaped('<em>Role name with markup</em>');
    $views_user = $this->drupalCreateUser([
        'administer views',
    ]);
    $this->drupalLogin($views_user);
    // Change the View to allow multiple values for the roles.
    $edit = [
        'options[break_phrase]' => TRUE,
    ];
    $this->drupalGet('admin/structure/views/nojs/handler/test_user_roles_rid/page_1/argument/roles_target_id');
    $this->submitForm($edit, 'Apply');
    $this->submitForm([], 'Save');
    $this->drupalGet('/user_roles_rid_test/markup_role_name+second_role_name');
    $this->assertSession()
        ->pageTextContains('User with role one');
    $this->assertSession()
        ->pageTextContains('User with role two');
}

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