public function testEnhancer() { $route_enhancer =
new EntityRouteEnhancer();
// Set a controller to ensure it is not overridden.
$request =
new Request();
$defaults =
[];
$defaults['_controller'
] = 'Drupal\Tests\Core\Controller\TestController::content';
$defaults['_entity_form'
] = 'entity_test.default';
$defaults['_route_object'
] =
(new Route('/test',
$defaults));
$new_defaults =
$route_enhancer->
enhance($defaults,
$request);
$this->
assertEquals($defaults['_controller'
],
$new_defaults['_controller'
], '_controller did not get overridden.'
);
// Set _entity_form and ensure that the form is set.
$defaults =
[];
$defaults['_entity_form'
] = 'entity_test.default';
$defaults['_route_object'
] =
(new Route('/test',
$defaults));
$new_defaults =
$route_enhancer->
enhance($defaults,
$request);
$this->
assertEquals('controller.entity_form:getContentResult',
$new_defaults['_controller'
]);
// Set _entity_list and ensure that the entity list controller is set.
$defaults =
[];