function DefaultHtmlRouteProviderTest::providerTestGetAddFormRoute
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetAddFormRoute()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetAddFormRoute()
- 11.x core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetAddFormRoute()
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Routing/ DefaultHtmlRouteProviderTest.php, line 116
Class
- DefaultHtmlRouteProviderTest
- @coversDefaultClass \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider @group Entity
Namespace
Drupal\Tests\Core\Entity\RoutingCode
public static function providerTestGetAddFormRoute() {
$prophet = new Prophet();
$data = [];
$entity_type1 = static::getEntityType();
$entity_type1->hasLinkTemplate('add-form')
->willReturn(FALSE);
$data['no_add_form_link_template'] = [
NULL,
$entity_type1->reveal(),
];
$entity_type2 = static::getEntityType();
$entity_type2->getBundleEntityType()
->willReturn(NULL);
$entity_type2->hasLinkTemplate('add-form')
->willReturn(TRUE);
$entity_type2->id()
->willReturn('the_entity_type_id');
$entity_type2->getLinkTemplate('add-form')
->willReturn('/the/add/form/link/template');
$entity_type2->getFormClass('add')
->willReturn(NULL);
$entity_type2->getKey('bundle')
->willReturn(NULL);
$route = (new Route('/the/add/form/link/template'))->setDefaults([
'_entity_form' => 'the_entity_type_id.default',
'entity_type_id' => 'the_entity_type_id',
'_title_callback' => 'Drupal\\Core\\Entity\\Controller\\EntityController::addTitle',
])
->setRequirement('_entity_create_access', 'the_entity_type_id');
$data['no_add_form_no_bundle'] = [
clone $route,
$entity_type2->reveal(),
];
$entity_type3 = static::getEntityType($entity_type2);
$entity_type3->getFormClass('add')
->willReturn('Drupal\\Core\\Entity\\EntityForm');
$route->setDefault('_entity_form', 'the_entity_type_id.add');
$data['add_form_no_bundle'] = [
clone $route,
$entity_type3->reveal(),
];
$entity_type4 = static::getEntityType($entity_type3);
$entity_type4->getKey('bundle')
->willReturn('the_bundle_key');
$entity_type4->getBundleEntityType()
->willReturn(NULL);
$entity_type4->getLinkTemplate('add-form')
->willReturn('/the/add/form/link/template/{the_bundle_key}');
$route->setPath('/the/add/form/link/template/{the_bundle_key}');
$route->setDefault('_title_callback', 'Drupal\\Core\\Entity\\Controller\\EntityController::addBundleTitle')
->setDefault('bundle_parameter', 'the_bundle_key')
->setRequirement('_entity_create_access', 'the_entity_type_id:{the_bundle_key}');
$data['add_form_bundle_static'] = [
clone $route,
$entity_type4->reveal(),
];
$entity_type5 = static::getEntityType($entity_type4);
$entity_type5->getBundleEntityType()
->willReturn('the_bundle_entity_type_id');
$entity_type5->getLinkTemplate('add-form')
->willReturn('/the/add/form/link/template/{the_bundle_entity_type_id}');
$bundle_entity_type = static::getEntityType();
$bundle_entity_type->entityClassImplements(FieldableEntityInterface::class)
->willReturn(FALSE);
$route->setPath('/the/add/form/link/template/{the_bundle_entity_type_id}');
$route->setDefault('bundle_parameter', 'the_bundle_entity_type_id')
->setRequirement('_entity_create_access', 'the_entity_type_id:{the_bundle_entity_type_id}')
->setOption('parameters', [
'the_bundle_entity_type_id' => [
'type' => 'entity:the_bundle_entity_type_id',
],
]);
$data['add_form_bundle_entity_id_key_type_null'] = [
clone $route,
$entity_type5->reveal(),
$bundle_entity_type->reveal(),
];
$entity_type6 = static::getEntityType($entity_type5);
$bundle_entity_type = static::getEntityType();
$bundle_entity_type->entityClassImplements(FieldableEntityInterface::class)
->willReturn(TRUE);
$field_storage_definition = $prophet->prophesize(FieldStorageDefinitionInterface::class);
$field_storage_definition->getType()
->willReturn('integer');
$route->setRequirement('the_entity_type_id', '\\d+');
$data['add_form_bundle_entity_id_key_type_integer'] = [
clone $route,
$entity_type6->reveal(),
$bundle_entity_type->reveal(),
$field_storage_definition->reveal(),
];
$entity_type7 = static::getEntityType($entity_type6);
$bundle_entity_type = $prophet->prophesize(ConfigEntityTypeInterface::class);
$bundle_entity_type->entityClassImplements(FieldableEntityInterface::class)
->willReturn(FALSE);
$field_storage_definition = $prophet->prophesize(FieldStorageDefinitionInterface::class);
$route->setRequirements([
'_entity_create_access' => $route->getRequirement('_entity_create_access'),
])
->setOption('parameters', [
'the_bundle_entity_type_id' => [
'type' => 'entity:the_bundle_entity_type_id',
'with_config_overrides' => TRUE,
],
]);
$data['add_form_bundle_entity_id_key_type_integer'] = [
clone $route,
$entity_type7->reveal(),
$bundle_entity_type->reveal(),
$field_storage_definition->reveal(),
];
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.