protected function OgAccessTestBase::groupEntity in Organic groups 8
Returns a mocked test group.
Parameters
bool $is_owner: Whether or not this test group should be owned by the test user which is used in the test.
Return value
\Drupal\Core\Entity\EntityInterface|\Prophecy\Prophecy\ObjectProphecy The test group.
File
- tests/
src/ Unit/ OgAccessTestBase.php, line 220
Class
- OgAccessTestBase
- Base class for tests of the OgAccess class.
Namespace
Drupal\Tests\og\UnitCode
protected function groupEntity($is_owner = FALSE) {
$entity_type = $this
->prophesize(EntityTypeInterface::class);
$entity_type
->id()
->willReturn($this->entityTypeId);
$group_entity = $this
->prophesize(EntityInterface::class);
if ($is_owner) {
$group_entity
->willImplement(EntityOwnerInterface::class);
// Our test user is hardcoded to have UID 2.
$group_entity
->getOwnerId()
->willReturn(2);
}
$group_entity
->getEntityType()
->willReturn($entity_type);
$group_entity
->getEntityTypeId()
->willReturn($this->entityTypeId);
$group_entity
->bundle()
->willReturn($this->bundle);
$group_entity
->id()
->willReturn($this->groupId);
return $this
->addCache($group_entity);
}