You are here

public function GroupRoleSynchronizationTest::testUserRoleUpdate in Group 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/GroupRoleSynchronizationTest.php \Drupal\Tests\group\Kernel\GroupRoleSynchronizationTest::testUserRoleUpdate()

Tests whether an updated user role syncs to group roles.

@covers \Drupal\group\Entity\Storage\GroupRoleStorage::updateSynchronizedLabels @depends testUserRoleCreation @uses group_user_role_update

File

tests/src/Kernel/GroupRoleSynchronizationTest.php, line 78

Class

GroupRoleSynchronizationTest
Tests whether group roles are actually synchronized.

Namespace

Drupal\Tests\group\Kernel

Code

public function testUserRoleUpdate() {
  $role = $this
    ->createUserRole('editor');
  $role
    ->set('label', 'Super-editor');
  $role
    ->save();
  $defaultGroupRoleId = $this->groupRoleSynchronizer
    ->getGroupRoleId('default', $role
    ->id());
  $group_role = $this->entityTypeManager
    ->getStorage('group_role')
    ->load($defaultGroupRoleId);
  $this
    ->assertEquals('Super-editor', $group_role
    ->label(), 'Updated synchronized roles share the same label');
}