function UserAccessControlHandlerTest::hiddenUserSettingsProvider

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::hiddenUserSettingsProvider()
  2. 10 core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::hiddenUserSettingsProvider()
  3. 11.x core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::hiddenUserSettingsProvider()

Provides test data for testHiddenUserSettings().

File

core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php, line 219

Class

UserAccessControlHandlerTest
Tests the user access controller.

Namespace

Drupal\Tests\user\Unit

Code

public function hiddenUserSettingsProvider() {
    $access_info = [];
    $fields = [
        'preferred_langcode',
        'preferred_admin_langcode',
        'timezone',
        'mail',
    ];
    foreach ($fields as $field) {
        $access_info[] = [
            'field' => $field,
            'viewer' => 'viewer',
            'target' => 'viewer',
            'view' => TRUE,
            'edit' => TRUE,
        ];
        $access_info[] = [
            'field' => $field,
            'viewer' => 'viewer',
            'target' => 'owner',
            'view' => FALSE,
            // Anyone with edit access to the user can also edit these fields. In
            // reality edit access will already be checked on entity level and the
            // user without view access will typically not be able to edit.
'edit' => TRUE,
        ];
        $access_info[] = [
            'field' => $field,
            'viewer' => 'owner',
            'target' => 'owner',
            'view' => TRUE,
            'edit' => TRUE,
        ];
        $access_info[] = [
            'field' => $field,
            'viewer' => 'admin',
            'target' => 'owner',
            'view' => TRUE,
            'edit' => TRUE,
        ];
        $access_info[] = [
            'field' => $field,
            'viewer' => 'emailViewer',
            'target' => 'owner',
            'view' => $field === 'mail',
            // See note above.
'edit' => TRUE,
        ];
    }
    return $access_info;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.