function UserAccessControlHandlerTest::userNameProvider

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::userNameProvider()
  2. 8.9.x core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::userNameProvider()
  3. 10 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 170

Class

UserAccessControlHandlerTest
Tests the user access controller.

Namespace

Drupal\Tests\user\Unit

Code

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

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