You are here

public function UserAccessControlHandlerTest::userNameProvider in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::userNameProvider()

Provides test data for testUserNameAccess().

File

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

Class

UserAccessControlHandlerTest
Tests the user access controller.

Namespace

Drupal\Tests\user\Unit

Code

public function userNameProvider() {
  $name_access = [
    // The viewer user is allowed to see user names on all accounts.
    [
      'viewer' => 'viewer',
      'target' => 'viewer',
      'view' => TRUE,
      'edit' => FALSE,
    ],
    [
      'viewer' => 'owner',
      'target' => 'viewer',
      'view' => TRUE,
      'edit' => FALSE,
    ],
    [
      'viewer' => 'viewer',
      'target' => 'owner',
      'view' => TRUE,
      'edit' => FALSE,
    ],
    // The owner user is allowed to change its own user name.
    [
      'viewer' => 'owner',
      'target' => 'owner',
      'view' => TRUE,
      'edit' => TRUE,
    ],
    // The users-administrator user has full access.
    [
      'viewer' => 'admin',
      'target' => 'owner',
      'view' => TRUE,
      'edit' => TRUE,
    ],
  ];
  return $name_access;
}