public function AccessByOgMembershipTest::testNonMemberRoleMembershipSave in Organic groups 8
Tests exception is thrown when trying to save non-member role.
File
- tests/
src/ Kernel/ Access/ AccessByOgMembershipTest.php, line 189
Class
- AccessByOgMembershipTest
- Tests access to content by OgMembership.
Namespace
Drupal\Tests\og\Kernel\AccessCode
public function testNonMemberRoleMembershipSave() {
/** @var \Drupal\og\Entity\OgRole $role */
$role = OgRole::getRole('block_content', 'group', OgRoleInterface::ANONYMOUS);
$role
->grantPermission('edit any group_content content')
->save();
$membership = OgMembership::create();
$this
->expectException(EntityStorageException::class);
$membership
->setOwner($this->users['non-member'])
->setGroup($this->group)
->addRole($role)
->setState(OgMembershipInterface::STATE_ACTIVE)
->save();
}