public function GroupRoleSynchronizationTest::testUserRoleCreation in Group 2.0.x
Same name and namespace in other branches
- 8 tests/src/Kernel/GroupRoleSynchronizationTest.php \Drupal\Tests\group\Kernel\GroupRoleSynchronizationTest::testUserRoleCreation()
Tests whether a new user role syncs to group roles.
@covers \Drupal\group\Entity\Storage\GroupRoleStorage::createSynchronized @uses group_user_role_insert
File
- tests/
src/ Kernel/ GroupRoleSynchronizationTest.php, line 59
Class
- GroupRoleSynchronizationTest
- Tests whether group roles are actually synchronized.
Namespace
Drupal\Tests\group\KernelCode
public function testUserRoleCreation() {
$role = $this
->createUserRole('editor');
$defaultGroupRoleId = $this->groupRoleSynchronizer
->getGroupRoleId('default', $role
->id());
$otherGroupRoleId = $this->groupRoleSynchronizer
->getGroupRoleId('other', $role
->id());
$group_roles = $this->entityTypeManager
->getStorage('group_role')
->loadMultiple();
$this
->assertArrayHasKey($defaultGroupRoleId, $group_roles, 'Synchronized role found for default group type');
$this
->assertArrayHasKey($otherGroupRoleId, $group_roles, 'Synchronized role found for other group type');
$this
->assertEquals($role
->label(), $group_roles[$otherGroupRoleId]
->label(), 'Synchronized roles share the same label');
$this
->assertEquals($role
->getWeight(), $group_roles[$otherGroupRoleId]
->getWeight(), 'Synchronized roles share the same weight');
}