function WorkspacesMediaLibraryIntegrationTest::drupalCreateUser

Create a user with a given set of permissions.

Parameters

array $permissions: Array of permission names to assign to user. Note that the user always has the default permissions derived from the "authenticated users" role.

string $name: The user name.

bool $admin: (optional) Whether the user should be an administrator with all the available permissions.

array $values: (optional) An array of initial user field values.

Return value

\Drupal\user\Entity\User|false A fully loaded user object with pass_raw property, or FALSE if account creation fails.

Overrides UserCreationTrait::createUser

File

core/modules/workspaces/tests/src/FunctionalJavascript/WorkspacesMediaLibraryIntegrationTest.php, line 58

Class

WorkspacesMediaLibraryIntegrationTest
Tests the Media library entity reference widget in a workspace.

Namespace

Drupal\Tests\workspaces\FunctionalJavascript

Code

protected function drupalCreateUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) : UserInterface|false {
  // Ensure that users and roles are managed outside a workspace context.
  return \Drupal::service('workspaces.manager')->executeOutsideWorkspace(function () use ($permissions, $name, $admin, $values) {
    $permissions = array_merge($permissions, [
      'view any workspace',
    ]);
    return parent::drupalCreateUser($permissions, $name, $admin, $values);
  });
}

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