You are here

protected function OgGroupResolverTestBase::createMockedEntity in Organic groups 8

Creates a mocked content entity to use in the test.

Parameters

string $id: The entity ID to assign to the mocked entity.

array $properties: An associative array of properties to assign to the mocked entity, with the following keys:

  • type: The entity type.
  • bundle: The entity bundle.

Return value

\Drupal\Core\Entity\ContentEntityInterface|\Prophecy\Prophecy\ObjectProphecy The mocked entity.

2 calls to OgGroupResolverTestBase::createMockedEntity()
OgGroupResolverTestBase::setUp in tests/src/Unit/Plugin/OgGroupResolver/OgGroupResolverTestBase.php
UserGroupAccessResolverTest::createMockedEntity in tests/src/Unit/Plugin/OgGroupResolver/UserGroupAccessResolverTest.php
Creates a mocked content entity to use in the test.
1 method overrides OgGroupResolverTestBase::createMockedEntity()
UserGroupAccessResolverTest::createMockedEntity in tests/src/Unit/Plugin/OgGroupResolver/UserGroupAccessResolverTest.php
Creates a mocked content entity to use in the test.

File

tests/src/Unit/Plugin/OgGroupResolver/OgGroupResolverTestBase.php, line 206

Class

OgGroupResolverTestBase
Base class for testing OgGroupResolver plugins.

Namespace

Drupal\Tests\og\Unit\Plugin\OgGroupResolver

Code

protected function createMockedEntity($id, array $properties) {

  /** @var \Drupal\Core\Entity\ContentEntityInterface|\Prophecy\Prophecy\ObjectProphecy $entity */
  $entity = $this
    ->prophesize(ContentEntityInterface::class);

  // In case this entity is questioned about its identity, it shall
  // willingly pony up the requested information.
  $entity
    ->id()
    ->willReturn($id);
  $entity
    ->getEntityTypeId()
    ->willReturn($properties['type']);
  $entity
    ->bundle()
    ->willReturn($properties['bundle']);
  return $entity;
}