EntityRouteEnhancer example


class EntityRouteEnhancerTest extends UnitTestCase {

  /** * Tests the enhancer method. * * @see \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhancer() */
  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.
Home | Imprint | This part of the site doesn't use cookies.