You are here

public function EntityResolverManagerTest::testSetRouteOptionsWithEntityUpcastingNoCreate in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php \Drupal\Tests\Core\Entity\EntityResolverManagerTest::testSetRouteOptionsWithEntityUpcastingNoCreate()

Tests setRouteOptions() with entity form upcasting, no create method.

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

File

core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php, line 254
Contains \Drupal\Tests\Core\Entity\EntityResolverManagerTest.

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

public function testSetRouteOptionsWithEntityUpcastingNoCreate() {
  $this
    ->setupEntityTypes();
  $route = new Route('/example/{entity_test}', [
    '_form' => 'Drupal\\Tests\\Core\\Entity\\BasicFormNoContainerInjectionInterface',
  ]);
  $defaults = $route
    ->getDefaults();
  $this->entityResolverManager
    ->setRouteOptions($route);
  $this
    ->assertEquals($defaults, $route
    ->getDefaults());
  $parameters = $route
    ->getOption('parameters');
  $this
    ->assertEquals([
    'entity_test' => [
      'type' => 'entity:entity_test',
    ],
  ], $parameters);
}