protected function GroupLevelAccessTest::createUserWithOgRole in Organic groups 8
Creates a test user and assigns it a membership with the given role.
Parameters
\Drupal\og\OgRoleInterface $role: The OG role to assign to the newly created user.
Return value
\Drupal\user\UserInterface The newly created user.
3 calls to GroupLevelAccessTest::createUserWithOgRole()
- GroupLevelAccessTest::setUp in tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php - GroupLevelAccessTest::setupGroupEntityOperationPermissions in tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php - Returns test users with permissions to perform group entity operations.
- GroupLevelAccessTest::setupUserAccessArbitraryPermissions in tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php - Sets up a matrix of users and roles with arbitrary permissions.
File
- tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php, line 407
Class
- GroupLevelAccessTest
- Tests user access to group level entity operations and permissions.
Namespace
Drupal\Tests\og\Kernel\AccessCode
protected function createUserWithOgRole(OgRoleInterface $role) : UserInterface {
$user = User::create([
'name' => $this
->randomString(),
]);
$user
->save();
$membership = Og::createMembership($this->group, $user);
$membership
->addRole($role)
->save();
return $user;
}