You are here

public function UserAccessControlHandlerTest::hiddenUserSettingsProvider in Drupal 9

Same name and namespace in other branches
  1. 8 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 220

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;
}