You are here

protected function ContentAccessTest::createUser in Search API 8

Creates a new user account.

Parameters

string[] $permissions: The permissions to set for the user.

Return value

\Drupal\user\UserInterface The new user object.

2 calls to ContentAccessTest::createUser()
ContentAccessTest::testQueryAccessOwn in tests/src/Kernel/Processor/ContentAccessTest.php
Tests searching for own unpublished content.
ContentAccessTest::testQueryAccessWithNodeGrants in tests/src/Kernel/Processor/ContentAccessTest.php
Tests building the query when content is accessible based on node grants.

File

tests/src/Kernel/Processor/ContentAccessTest.php, line 380

Class

ContentAccessTest
Tests the "Content access" processor.

Namespace

Drupal\Tests\search_api\Kernel\Processor

Code

protected function createUser(array $permissions) {
  $role = Role::create([
    'id' => 'role',
    'name' => 'Role test',
  ]);
  $role
    ->save();
  user_role_grant_permissions($role
    ->id(), $permissions);
  $values = [
    'uid' => 2,
    'name' => 'Test',
    'roles' => [
      $role
        ->id(),
    ],
  ];
  $authenticated_user = User::create($values);
  $authenticated_user
    ->enforceIsNew();
  $authenticated_user
    ->save();
  return $authenticated_user;
}