You are here

public function GroupRoleSynchronizationTest::testGroupTypeCreation in Group 8

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

Tests whether a new group type receives synchronized group roles.

@covers \Drupal\group\Entity\Storage\GroupRoleStorage::createSynchronized @uses \Drupal\group\Entity\GroupType::postSave

File

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

Class

GroupRoleSynchronizationTest
Tests whether group roles are actually synchronized.

Namespace

Drupal\Tests\group\Kernel

Code

public function testGroupTypeCreation() {
  $role = $this
    ->createUserRole('editor');
  $group_type = $this->entityTypeManager
    ->getStorage('group_type')
    ->create([
    'id' => $this
      ->randomMachineName(),
    'label' => $this
      ->randomString(),
  ]);
  $group_type
    ->save();
  $group_roles = $this->entityTypeManager
    ->getStorage('group_role')
    ->loadMultiple();
  $group_role_id = $this->groupRoleSynchronizer
    ->getGroupRoleId($group_type
    ->id(), $role
    ->id());
  $this
    ->assertArrayHasKey($group_role_id, $group_roles, 'Synchronized role found for new group type');
}