AccessRoleUITest.php in Zircon Profile 8
File
core/modules/user/src/Tests/Views/AccessRoleUITest.php
View source
<?php
namespace Drupal\user\Tests\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\views_ui\Tests\UITestBase;
class AccessRoleUITest extends UITestBase {
public static $testViews = array(
'test_access_role',
);
public static $modules = array(
'user',
'user_test_views',
);
protected function setUp() {
parent::setUp();
ViewTestData::createTestViews(get_class($this), array(
'user_test_views',
));
}
public function testAccessRoleUI() {
$entity_manager = $this->container
->get('entity.manager');
$entity_manager
->getStorage('user_role')
->create(array(
'id' => 'custom_role',
'label' => 'Custom role',
))
->save();
$access_url = "admin/structure/views/nojs/display/test_access_role/default/access_options";
$this
->drupalPostForm($access_url, array(
'access_options[role][custom_role]' => 1,
), t('Apply'));
$this
->assertResponse(200);
$this
->drupalPostForm(NULL, array(), t('Save'));
$view = $entity_manager
->getStorage('view')
->load('test_access_role');
$display = $view
->getDisplay('default');
$this
->assertEqual($display['display_options']['access']['options']['role'], array(
'custom_role' => 'custom_role',
));
$this
->drupalPostForm('admin/structure/views/nojs/display/test_access_role/default/access', [
'access[type]' => 'none',
], t('Apply'));
$this
->drupalPostForm(NULL, array(), t('Save'));
$view = $entity_manager
->getStorage('view')
->load('test_access_role');
$display = $view
->getDisplay('default');
$this
->assertFalse(isset($display['display_options']['access']['options']['role']));
}
}