Pull merge.
[yaffs-website] / web / core / modules / user / tests / src / Functional / Views / UserFieldsAccessChangeTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Functional\Views;
4
5 /**
6  * Checks if user fields access permissions can be modified by other modules.
7  *
8  * @group user
9  */
10 class UserFieldsAccessChangeTest extends UserTestBase {
11
12   /**
13    * Modules to enable.
14    *
15    * @var array
16    */
17   public static $modules = ['user_access_test'];
18
19   /**
20    * Views used by this test.
21    *
22    * @var array
23    */
24   public static $testViews = ['test_user_fields_access'];
25
26   /**
27    * Tests if another module can change field access.
28    */
29   public function testUserFieldAccess() {
30     $path = 'test_user_fields_access';
31     $this->drupalGet($path);
32
33     // User has access to name and created date by default.
34     $this->assertText(t('Name'));
35     $this->assertText(t('Created'));
36
37     // User does not by default have access to init, mail and status.
38     $this->assertNoText(t('Init'));
39     $this->assertNoText(t('Email'));
40     $this->assertNoText(t('Status'));
41
42     // Assign sub-admin role to grant extra access.
43     $user = $this->drupalCreateUser(['sub-admin']);
44     $this->drupalLogin($user);
45     $this->drupalGet($path);
46
47     // Access for init, mail and status is added in hook_entity_field_access().
48     $this->assertText(t('Init'));
49     $this->assertText(t('Email'));
50     $this->assertText(t('Status'));
51   }
52
53 }