function DefaultHtmlRouteProviderTest::providerTestGetCollectionRoute
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCollectionRoute()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCollectionRoute()
- 11.x core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCollectionRoute()
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Routing/ DefaultHtmlRouteProviderTest.php, line 268
Class
- DefaultHtmlRouteProviderTest
- @coversDefaultClass \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider @group Entity
Namespace
Drupal\Tests\Core\Entity\RoutingCode
public static function providerTestGetCollectionRoute() {
$data = [];
$entity_type1 = static::getEntityType();
$entity_type1->hasLinkTemplate('collection')
->willReturn(FALSE);
$entity_type1->getAdminPermission()
->willReturn(FALSE);
$entity_type1->getCollectionPermission()
->willReturn(NULL);
$data['no_collection_link_template'] = [
NULL,
$entity_type1->reveal(),
];
$entity_type2 = static::getEntityType();
$entity_type2->getAdminPermission()
->willReturn(FALSE);
$entity_type2->getCollectionPermission()
->willReturn(NULL);
$entity_type2->hasLinkTemplate('collection')
->willReturn(TRUE);
$entity_type2->hasListBuilderClass()
->willReturn(FALSE);
$data['no_list_builder'] = [
NULL,
$entity_type2->reveal(),
];
$entity_type3 = static::getEntityType($entity_type2);
$entity_type3->hasListBuilderClass()
->willReturn(TRUE);
$entity_type3->getAdminPermission()
->willReturn(FALSE);
$entity_type3->getCollectionPermission()
->willReturn(NULL);
$data['no_permission'] = [
NULL,
$entity_type3->reveal(),
];
$entity_type4 = static::getEntityType($entity_type3);
$entity_type4->getAdminPermission()
->willReturn(FALSE);
$entity_type4->getCollectionPermission()
->willReturn('overview the entity type');
$entity_type4->id()
->willReturn('the_entity_type_id');
$entity_type4->getLabel()
->willReturn('The entity type');
$entity_type4->getCollectionLabel()
->willReturn(new TranslatableMarkup('Test entities'));
$entity_type4->getLinkTemplate('collection')
->willReturn('/the/collection/link/template');
$entity_type4->entityClassImplements(FieldableEntityInterface::class)
->willReturn(FALSE);
$route = (new Route('/the/collection/link/template'))->setDefaults([
'_entity_list' => 'the_entity_type_id',
'_title' => 'Test entities',
'_title_arguments' => [],
'_title_context' => '',
])
->setRequirements([
'_permission' => 'overview the entity type',
]);
$data['collection_route_with_collection_permission'] = [
clone $route,
$entity_type4->reveal(),
];
$entity_type5 = static::getEntityType($entity_type4);
$entity_type5->getAdminPermission()
->willReturn('administer the entity type');
$entity_type5->getCollectionPermission()
->willReturn(NULL);
$entity_type5->id()
->willReturn('the_entity_type_id');
$entity_type5->getLabel()
->willReturn('The entity type');
$entity_type5->getCollectionLabel()
->willReturn(new TranslatableMarkup('Test entities'));
$entity_type5->getLinkTemplate('collection')
->willReturn('/the/collection/link/template');
$entity_type5->entityClassImplements(FieldableEntityInterface::class)
->willReturn(FALSE);
$route = (new Route('/the/collection/link/template'))->setDefaults([
'_entity_list' => 'the_entity_type_id',
'_title' => 'Test entities',
'_title_arguments' => [],
'_title_context' => '',
])
->setRequirements([
'_permission' => 'administer the entity type',
]);
$data['collection_route_with_admin_permission'] = [
clone $route,
$entity_type5->reveal(),
];
$entity_type6 = static::getEntityType($entity_type5);
$entity_type6->getAdminPermission()
->willReturn('administer the entity type');
$entity_type6->getCollectionPermission()
->willReturn('overview the entity type');
$entity_type6->id()
->willReturn('the_entity_type_id');
$entity_type6->getLabel()
->willReturn('The entity type');
$entity_type6->getCollectionLabel()
->willReturn(new TranslatableMarkup('Test entities'));
$entity_type6->getLinkTemplate('collection')
->willReturn('/the/collection/link/template');
$entity_type6->entityClassImplements(FieldableEntityInterface::class)
->willReturn(FALSE);
$route = (new Route('/the/collection/link/template'))->setDefaults([
'_entity_list' => 'the_entity_type_id',
'_title' => 'Test entities',
'_title_arguments' => [],
'_title_context' => '',
])
->setRequirements([
'_permission' => 'administer the entity type+overview the entity type',
]);
$data['collection_route_with_both_permission'] = [
clone $route,
$entity_type6->reveal(),
];
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.