function ContextualFiltersStringTest::testUserRoleContextualFilter
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/ContextualFiltersStringTest.php \Drupal\Tests\views\Functional\Plugin\ContextualFiltersStringTest::testUserRoleContextualFilter()
- 10 core/modules/views/tests/src/Functional/Plugin/ContextualFiltersStringTest.php \Drupal\Tests\views\Functional\Plugin\ContextualFiltersStringTest::testUserRoleContextualFilter()
Tests contextual filter for the user roles.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ ContextualFiltersStringTest.php, line 72
Class
- ContextualFiltersStringTest
- Test contextual filters with 'allow multiple values' setting for user roles.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testUserRoleContextualFilter() : void {
$this->drupalGet('admin/structure/views/view/test_user_role_contextual_filter');
$edit = [
'view_args' => $this->role1,
];
$this->submitForm($edit, 'Update preview');
$this->assertSession()
->pageTextContains('user1');
$this->assertSession()
->pageTextContains('user3');
$this->assertSession()
->pageTextContains('user5');
$this->assertSession()
->pageTextNotContains('user2');
$this->assertSession()
->pageTextNotContains('user4');
$edit = [
'view_args' => $this->role2,
];
$this->submitForm($edit, 'Update preview');
$this->assertSession()
->pageTextContains('user2');
$this->assertSession()
->pageTextContains('user3');
$this->assertSession()
->pageTextContains('user4');
$this->assertSession()
->pageTextContains('user5');
$this->assertSession()
->pageTextNotContains('user1');
$edit = [
'view_args' => "{$this->role1},{$this->role2}",
];
$this->submitForm($edit, 'Update preview');
$this->assertSession()
->pageTextContains('user3');
$this->assertSession()
->pageTextContains('user5');
$this->assertSession()
->pageTextNotContains('user1');
$this->assertSession()
->pageTextNotContains('user2');
$this->assertSession()
->pageTextNotContains('user4');
$edit = [
'view_args' => "{$this->role1}+{$this->role2}",
];
$this->submitForm($edit, 'Update preview');
$this->assertSession()
->pageTextContains('user1');
$this->assertSession()
->pageTextContains('user2');
$this->assertSession()
->pageTextContains('user3');
$this->assertSession()
->pageTextContains('user4');
$this->assertSession()
->pageTextContains('user5');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.