You are here

protected function GroupRoleSynchronizerTest::setUpConfigEntityStorage in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/GroupRoleSynchronizerTest.php \Drupal\Tests\group\Unit\GroupRoleSynchronizerTest::setUpConfigEntityStorage()

Mock and set up a config entity type's storage handler.

Parameters

string $entity_type_id: The ID of the config entity type to mock the storage for.

string[] $entity_ids: The IDs of the config entities to return from an entity query.

\Drupal\Core\Config\Entity\ConfigEntityInterface[] $entities: The config entities to return from a loadMultiple() call.

4 calls to GroupRoleSynchronizerTest::setUpConfigEntityStorage()
GroupRoleSynchronizerTest::testGetGroupRoleIdsByGroupType in tests/src/Unit/GroupRoleSynchronizerTest.php
@covers ::getGroupRoleIdsByGroupType @depends testGetGroupRoleId
GroupRoleSynchronizerTest::testGetGroupRoleIdsByGroupTypes in tests/src/Unit/GroupRoleSynchronizerTest.php
@covers ::getGroupRoleIdsByGroupTypes @depends testGetGroupRoleId
GroupRoleSynchronizerTest::testGetGroupRoleIdsByUserRole in tests/src/Unit/GroupRoleSynchronizerTest.php
@covers ::getGroupRoleIdsByUserRole @depends testGetGroupRoleId
GroupRoleSynchronizerTest::testGetGroupRoleIdsByUserRoles in tests/src/Unit/GroupRoleSynchronizerTest.php
@covers ::getGroupRoleIdsByUserRoles @depends testGetGroupRoleId

File

tests/src/Unit/GroupRoleSynchronizerTest.php, line 118

Class

GroupRoleSynchronizerTest
Tests the outsider group role synchronizer service.

Namespace

Drupal\Tests\group\Unit

Code

protected function setUpConfigEntityStorage($entity_type_id, $entity_ids = [], $entities = []) {
  $storage = $this
    ->prophesize(ConfigEntityStorageInterface::class);
  if (!empty($entity_ids)) {
    $query = $this
      ->prophesize(QueryInterface::class);
    $query
      ->execute()
      ->willReturn($entity_ids);
    $storage
      ->getQuery()
      ->willReturn($query
      ->reveal());
  }
  if (!empty($entities)) {
    $storage
      ->loadMultiple(NULL)
      ->willReturn($entities);
    $storage
      ->loadMultiple(array_keys($entities))
      ->willReturn($entities);
  }
  $this->entityTypeManager
    ->getStorage($entity_type_id)
    ->willReturn($storage
    ->reveal());
}