class AccessRoleUITest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Functional/AccessRoleUITest.php \Drupal\Tests\user\Functional\AccessRoleUITest
Tests views role access plugin UI.
@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\views_ui\Functional\UITestBase implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\user\Functional\AccessRoleUITest implements \Drupal\Tests\views_ui\Functional\UITestBase
- class \Drupal\Tests\views_ui\Functional\UITestBase 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 AccessRoleUITest
See also
\Drupal\user\Plugin\views\access\Role
File
-
core/
modules/ user/ tests/ src/ Functional/ AccessRoleUITest.php, line 13
Namespace
Drupal\Tests\user\FunctionalView source
class AccessRoleUITest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_access_role',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'user',
'user_test_views',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'user_test_views',
]) : void {
parent::setUp($import_test_views, $modules);
}
/**
* Tests the role access plugin UI.
*/
public function testAccessRoleUI() {
$entity_type_manager = $this->container
->get('entity_type.manager');
$entity_type_manager->getStorage('user_role')
->create([
'id' => 'custom_role',
'label' => 'Custom role',
])
->save();
$access_url = "admin/structure/views/nojs/display/test_access_role/default/access_options";
$this->drupalGet($access_url);
$this->submitForm([
'access_options[role][custom_role]' => 1,
], 'Apply');
$this->assertSession()
->statusCodeEquals(200);
$this->submitForm([], 'Save');
$view = $entity_type_manager->getStorage('view')
->load('test_access_role');
$display = $view->getDisplay('default');
$this->assertEquals([
'custom_role' => 'custom_role',
], $display['display_options']['access']['options']['role']);
// Test changing access plugin from role to none.
$this->drupalGet('admin/structure/views/nojs/display/test_access_role/default/access');
$this->submitForm([
'access[type]' => 'none',
], 'Apply');
$this->submitForm([], 'Save');
// Verify that role option is not set.
$view = $entity_type_manager->getStorage('view')
->load('test_access_role');
$display = $view->getDisplay('default');
$this->assertFalse(isset($display['display_options']['access']['options']['role']));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.