protected function GroupSubscribeFormTest::createUser in Organic groups 8
Creates a user.
Parameters
array $permissions: (optional) Array of permission names to assign to user.
Return value
\Drupal\user\Entity\User The created user entity.
1 call to GroupSubscribeFormTest::createUser()
- GroupSubscribeFormTest::testIsStateActive in tests/
src/ Kernel/ Form/ GroupSubscribeFormTest.php - Tests subscribe confirmation related text.
File
- tests/
src/ Kernel/ Form/ GroupSubscribeFormTest.php, line 196
Class
- GroupSubscribeFormTest
- Tests access to the create entity form through the user interface.
Namespace
Drupal\Tests\og\Kernel\FormCode
protected function createUser(array $permissions = []) {
$values = [];
if ($permissions) {
// Create a new role and apply permissions to it.
$role = Role::create([
'id' => strtolower($this
->randomMachineName(8)),
'label' => $this
->randomMachineName(8),
]);
$role
->save();
user_role_grant_permissions($role
->id(), $permissions);
$values['roles'][] = $role
->id();
}
$account = User::create($values + [
'name' => $this
->randomMachineName(),
'status' => 1,
]);
$account
->enforceIsNew();
$account
->save();
return $account;
}