Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/tests/src/Functional/AccessRoleUITest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\user\Functional; | |
4 | |
5 use Drupal\Tests\views_ui\Functional\UITestBase; | |
6 use Drupal\views\Tests\ViewTestData; | |
7 | |
8 /** | |
9 * Tests views role access plugin UI. | |
10 * | |
11 * @group user | |
12 * @see \Drupal\user\Plugin\views\access\Role | |
13 */ | |
14 class AccessRoleUITest extends UITestBase { | |
15 | |
16 /** | |
17 * Views used by this test. | |
18 * | |
19 * @var array | |
20 */ | |
21 public static $testViews = ['test_access_role']; | |
22 | |
23 /** | |
24 * Modules to enable. | |
25 * | |
26 * @var array | |
27 */ | |
28 public static $modules = ['user', 'user_test_views']; | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 */ | |
33 protected function setUp($import_test_views = TRUE) { | |
34 parent::setUp($import_test_views); | |
35 | |
36 ViewTestData::createTestViews(get_class($this), ['user_test_views']); | |
37 } | |
38 | |
39 /** | |
40 * Tests the role access plugin UI. | |
41 */ | |
42 public function testAccessRoleUI() { | |
43 $entity_manager = $this->container->get('entity.manager'); | |
44 $entity_manager->getStorage('user_role')->create(['id' => 'custom_role', 'label' => 'Custom role'])->save(); | |
45 $access_url = "admin/structure/views/nojs/display/test_access_role/default/access_options"; | |
46 $this->drupalPostForm($access_url, ['access_options[role][custom_role]' => 1], t('Apply')); | |
47 $this->assertResponse(200); | |
48 | |
49 $this->drupalPostForm(NULL, [], t('Save')); | |
50 $view = $entity_manager->getStorage('view')->load('test_access_role'); | |
51 | |
52 $display = $view->getDisplay('default'); | |
53 $this->assertEqual($display['display_options']['access']['options']['role'], ['custom_role' => 'custom_role']); | |
54 | |
55 // Test changing access plugin from role to none. | |
56 $this->drupalPostForm('admin/structure/views/nojs/display/test_access_role/default/access', ['access[type]' => 'none'], t('Apply')); | |
57 $this->drupalPostForm(NULL, [], t('Save')); | |
58 // Verify that role option is not set. | |
59 $view = $entity_manager->getStorage('view')->load('test_access_role'); | |
60 $display = $view->getDisplay('default'); | |
61 $this->assertFalse(isset($display['display_options']['access']['options']['role'])); | |
62 } | |
63 | |
64 } |