class RolesRidArgumentTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php \Drupal\Tests\user\Functional\Views\RolesRidArgumentTest
- 10 core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php \Drupal\Tests\user\Functional\Views\RolesRidArgumentTest
- 8.9.x core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php \Drupal\Tests\user\Functional\Views\RolesRidArgumentTest
Tests the handler of the user: roles argument.
@group user
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\user\Functional\Views\UserTestBase implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\user\Functional\Views\RolesRidArgumentTest implements \Drupal\Tests\user\Functional\Views\UserTestBase
- class \Drupal\Tests\user\Functional\Views\UserTestBase implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of RolesRidArgumentTest
See also
\Drupal\user\Plugin\views\argument\RolesRid
File
-
core/
modules/ user/ tests/ src/ Functional/ Views/ RolesRidArgumentTest.php, line 11
Namespace
Drupal\Tests\user\Functional\ViewsView source
class RolesRidArgumentTest extends UserTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_user_roles_rid',
];
/**
* {@inheritdoc}
*/
protected static $modules = [
'views_ui',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the generated title of a user: roles argument.
*/
public function testArgumentTitle() {
$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);
$user->save();
$second_user = $this->createUser([], 'User with role two');
$second_user->addRole('second_role_name');
$second_user->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.