3 namespace Drupal\Tests\user\Functional\Views;
6 * Checks if user fields access permissions can be modified by other modules.
10 class UserFieldsAccessChangeTest extends UserTestBase {
17 public static $modules = ['user_access_test'];
20 * Views used by this test.
24 public static $testViews = ['test_user_fields_access'];
27 * Tests if another module can change field access.
29 public function testUserFieldAccess() {
30 $path = 'test_user_fields_access';
31 $this->drupalGet($path);
33 // User has access to name and created date by default.
34 $this->assertText(t('Name'));
35 $this->assertText(t('Created'));
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'));
42 // Assign sub-admin role to grant extra access.
43 $user = $this->drupalCreateUser(['sub-admin']);
44 $this->drupalLogin($user);
45 $this->drupalGet($path);
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'));