You are here

protected function UserGroupAccessResolverTest::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.

Overrides OgGroupResolverTestBase::createMockedEntity

File

tests/src/Unit/Plugin/OgGroupResolver/UserGroupAccessResolverTest.php, line 86

Class

UserGroupAccessResolverTest
Tests the UserGroupAccessResolver plugin.

Namespace

Drupal\Tests\og\Unit\Plugin\OgGroupResolver

Code

protected function createMockedEntity($id, array $properties) {
  $entity = parent::createMockedEntity($id, $properties);

  // Mock the expected result of an access check on the entity.
  $entity
    ->access('view')
    ->willReturn($properties['current_user_has_access']);
  return $entity;
}