function EntityResolverManagerTest::testSetRouteOptionsWithEntityFormRouteAndArgument

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php \Drupal\Tests\Core\Entity\EntityResolverManagerTest::testSetRouteOptionsWithEntityFormRouteAndArgument()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php \Drupal\Tests\Core\Entity\EntityResolverManagerTest::testSetRouteOptionsWithEntityFormRouteAndArgument()
  3. 10 core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php \Drupal\Tests\Core\Entity\EntityResolverManagerTest::testSetRouteOptionsWithEntityFormRouteAndArgument()

Tests an _entity_form route where a non-entity parameter is first.

The {argument} preceding {entity_test} in route path, is upcasting with a custom param converter.

@covers ::setRouteOptions @covers ::getControllerClass @covers ::getEntityTypes @covers ::setParametersFromReflection @covers ::setParametersFromEntityInformation

File

core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php, line 398

Class

EntityResolverManagerTest
@coversDefaultClass \Drupal\Core\Entity\EntityResolverManager @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testSetRouteOptionsWithEntityFormRouteAndArgument() : void {
    $this->setupEntityTypes();
    $route = new Route('/example/{argument}/{entity_test}', [
        '_entity_form' => 'entity_test.edit',
    ]);
    // Add {argument} parameter configuration. In this case {argument} is
    // upcasted by a custom param converter 'argument_type'.
    $route->setOption('parameters', [
        'argument' => [
            'type' => 'argument_type',
        ],
    ]);
    $defaults = $route->getDefaults();
    $this->entityResolverManager
        ->setRouteOptions($route);
    $this->assertEquals($defaults, $route->getDefaults());
    $parameters = $route->getOption('parameters');
    $expect = [
        'argument' => [
            'type' => 'argument_type',
        ],
        'entity_test' => [
            'type' => 'entity:entity_test',
        ],
    ];
    $this->assertEquals($expect, $parameters);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.