public function DefaultHtmlRouteProviderTest::providerTestGetCanonicalRoute in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCanonicalRoute()
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ Routing/ DefaultHtmlRouteProviderTest.php, line 79 - Contains \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest.
Class
- DefaultHtmlRouteProviderTest
- @coversDefaultClass \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider @group Entity
Namespace
Drupal\Tests\Core\Entity\RoutingCode
public function providerTestGetCanonicalRoute() {
$data = [];
$entity_type1 = $this
->prophesize(EntityTypeInterface::class);
$entity_type1
->hasLinkTemplate('canonical')
->willReturn(FALSE);
$data['no_canonical_link_template'] = [
$entity_type1,
NULL,
];
$entity_type2 = $this
->prophesize(EntityTypeInterface::class);
$entity_type2
->hasLinkTemplate('canonical')
->willReturn(TRUE);
$entity_type2
->hasViewBuilderClass()
->willReturn(FALSE);
$data['no_view_builder'] = [
$entity_type2,
NULL,
];
$entity_type3 = $this
->prophesize(EntityTypeInterface::class);
$entity_type3
->hasLinkTemplate('canonical')
->willReturn(TRUE);
$entity_type3
->hasViewBuilderClass()
->willReturn(TRUE);
$entity_type3
->id()
->willReturn('the_entity_type_id');
$entity_type3
->getLinkTemplate('canonical')
->willReturn('/the/canonical/link/template');
$entity_type3
->isSubclassOf(FieldableEntityInterface::class)
->willReturn(FALSE);
$route3 = (new Route('/the/canonical/link/template'))
->setDefaults([
'_entity_view' => 'the_entity_type_id.full',
'_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
])
->setRequirements([
'_entity_access' => 'the_entity_type_id.view',
])
->setOptions([
'parameters' => [
'the_entity_type_id' => [
'type' => 'entity:the_entity_type_id',
],
],
]);
$data['id_key_type_null'] = [
$entity_type3,
$route3,
];
$entity_type4 = $this
->prophesize(EntityTypeInterface::class);
$entity_type4
->hasLinkTemplate('canonical')
->willReturn(TRUE);
$entity_type4
->hasViewBuilderClass()
->willReturn(TRUE);
$entity_type4
->id()
->willReturn('the_entity_type_id');
$entity_type4
->getLinkTemplate('canonical')
->willReturn('/the/canonical/link/template');
$entity_type4
->isSubclassOf(FieldableEntityInterface::class)
->willReturn(TRUE);
$entity_type4
->getKey('id')
->willReturn('id');
$route4 = (new Route('/the/canonical/link/template'))
->setDefaults([
'_entity_view' => 'the_entity_type_id.full',
'_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
])
->setRequirements([
'_entity_access' => 'the_entity_type_id.view',
'the_entity_type_id' => '\\d+',
])
->setOptions([
'parameters' => [
'the_entity_type_id' => [
'type' => 'entity:the_entity_type_id',
],
],
]);
$field_storage_definition = $this
->prophesize(FieldStorageDefinitionInterface::class);
$field_storage_definition
->getType()
->willReturn('integer');
$data['id_key_type_integer'] = [
$entity_type4,
$route4,
$field_storage_definition,
];
return $data;
}