protected function OgRouteGroupResolverTestBase::willRetrieveContentEntityPaths in Organic groups 8
Adds an expectation that the plugin will retrieve a list of entity paths.
The plugin need to match the current path to this list of entity paths to see if we are currently on an entity path of a group or group content entity. In order to retrieve the content entity paths, the plugin will have to request a full list of all entity types, then request the "link templates" from the content entities.
1 call to OgRouteGroupResolverTestBase::willRetrieveContentEntityPaths()
- OgRouteGroupResolverTestBase::testResolve in tests/
src/ Unit/ Plugin/ OgGroupResolver/ OgRouteGroupResolverTestBase.php - @todo Update documentation.
File
- tests/
src/ Unit/ Plugin/ OgGroupResolver/ OgRouteGroupResolverTestBase.php, line 178
Class
- OgRouteGroupResolverTestBase
- Base class for testing OgGroupResolver plugins that depend on the route.
Namespace
Drupal\Tests\og\Unit\Plugin\OgGroupResolverCode
protected function willRetrieveContentEntityPaths() {
// Provide some mocked content entity types.
$entity_types = [];
foreach (array_keys($this->linkTemplates) as $entity_type_id) {
/** @var \Drupal\Core\Entity\EntityTypeInterface|\Prophecy\Prophecy\ObjectProphecy $entity_type */
$entity_type = $this
->prophesize(EntityTypeInterface::class);
// The plugin will need to know if this is a content entity, so we will
// provide this information. We are not requiring this to be called since
// there are other ways of determining this (e.g. `instanceof`).
$entity_type
->entityClassImplements(ContentEntityInterface::class)
->willReturn(TRUE);
// The plugin will need to inquire about the link templates that the
// entity provides. This should be called.
$entity_type
->getLinkTemplates()
->willReturn($this
->getLinkTemplates($entity_type_id))
->shouldBeCalled();
$entity_types[$entity_type_id] = $entity_type
->reveal();
}
$this->entityTypeManager
->getDefinitions()
->willReturn($entity_types)
->shouldBeCalled();
}