You are here

protected function PremiumContentTest::createUser in Node Option Premium 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.

1 call to PremiumContentTest::createUser()
PremiumContentTest::testQueryAccessOwn in tests/src/Kernel/Plugin/search_api/processor/PremiumContentTest.php
Tests searching for own premium content.

File

tests/src/Kernel/Plugin/search_api/processor/PremiumContentTest.php, line 190

Class

PremiumContentTest
Tests the "Premium content" processor.

Namespace

Drupal\Tests\nopremium\Kernel\Plugin\search_api\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;
}