
| Current Path : /var/www/html/store/web/core/modules/user/tests/src/Functional/Views/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/store/web/core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php |
<?php
namespace Drupal\Tests\user\Functional\Views;
/**
* Tests the handler of the user: roles argument.
*
* @group user
* @see \Drupal\user\Plugin\views\argument\RolesRid
*/
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');
}
}