public function RouteProviderTest::testAdminHtmlRoutes in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php \Drupal\KernelTests\Core\Entity\RouteProviderTest::testAdminHtmlRoutes()
@covers \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider::getEditFormRoute @covers \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider::getDeleteFormRoute
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ RouteProviderTest.php, line 109 - Contains \Drupal\KernelTests\Core\Entity\RouteProviderTest.
Class
- RouteProviderTest
- Tests route providers for entity types.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testAdminHtmlRoutes() {
/** @var \Drupal\Core\Routing\RouteProviderInterface $route_provider */
$route_provider = \Drupal::service('router.route_provider');
$route = $route_provider
->getRouteByName('entity.entity_test_admin_routes.canonical');
$this
->assertEquals('entity_test_admin_routes.full', $route
->getDefault('_entity_view'));
$this
->assertEquals('\\Drupal\\Core\\Entity\\Controller\\EntityController::title', $route
->getDefault('_title_callback'));
$this
->assertEquals('entity_test_admin_routes.view', $route
->getRequirement('_entity_access'));
$this
->assertFalse($route
->hasOption('_admin_route'));
$route = $route_provider
->getRouteByName('entity.entity_test_admin_routes.edit_form');
$this
->assertEquals('entity_test_admin_routes.default', $route
->getDefault('_entity_form'));
$this
->assertEquals('\\Drupal\\Core\\Entity\\Controller\\EntityController::editTitle', $route
->getDefault('_title_callback'));
$this
->assertEquals('entity_test_admin_routes.update', $route
->getRequirement('_entity_access'));
$this
->assertTrue($route
->hasOption('_admin_route'));
$this
->assertTrue($route
->getOption('_admin_route'));
$route = $route_provider
->getRouteByName('entity.entity_test_admin_routes.delete_form');
$this
->assertEquals('entity_test_admin_routes.delete', $route
->getDefault('_entity_form'));
$this
->assertEquals('\\Drupal\\Core\\Entity\\Controller\\EntityController::deleteTitle', $route
->getDefault('_title_callback'));
$this
->assertEquals('entity_test_admin_routes.delete', $route
->getRequirement('_entity_access'));
$this
->assertTrue($route
->hasOption('_admin_route'));
$this
->assertTrue($route
->getOption('_admin_route'));
$entity = EntityTestAdminRoutes::create([
'name' => 'Test title',
]);
$entity
->save();
$this
->setRawContent($this
->httpKernelHandle($entity
->url()));
$this
->assertTitle('Test title | ');
$this
->setRawContent($this
->httpKernelHandle($entity
->url('edit-form')));
$this
->assertTitle('Edit Test title | ');
$this
->setRawContent($this
->httpKernelHandle($entity
->url('delete-form')));
$this
->assertTitle('Are you sure you want to delete the test entity - admin routes Test title? | ');
}