public function GroupCreatorTest::testCreatorRoles in Group 2.0.x
Same name and namespace in other branches
- 8 tests/src/Kernel/GroupCreatorTest.php \Drupal\Tests\group\Kernel\GroupCreatorTest::testCreatorRoles()
Tests that a group creator gets the configured roles.
@depends testCreatorGetsMembership
File
- tests/
src/ Kernel/ GroupCreatorTest.php, line 51
Class
- GroupCreatorTest
- Tests the behavior of group creators.
Namespace
Drupal\Tests\group\KernelCode
public function testCreatorRoles() {
/* @var \Drupal\group\Entity\GroupTypeInterface $group_type */
$group_type = $this->entityTypeManager
->getStorage('group_type')
->load('default');
$group_type
->set('creator_roles', [
'default-custom',
]);
$group_type
->save();
$group_roles = $this
->getCreatorRoles($this
->getCurrentUser(), $this
->createGroup());
$this
->assertCount(1, $group_roles, 'Membership has one role.');
$this
->assertEquals('default-custom', reset($group_roles)
->id(), 'Membership has the custom role.');
}