You are here

public function EntityRevisionRouteEnhancerTest::testEnhanceWithEntityRevision in Entity API 8.0

@covers ::enhance

File

tests/src/Unit/RouteEnhancer/EntityRevisionRouteEnhancerTest.php, line 80
Contains \Drupal\Tests\Unit\RouteEnhancer\EntityRevisionRouteEnhancerTest.

Class

EntityRevisionRouteEnhancerTest
@coversDefaultClass \Drupal\entity\RouteEnhancer\EntityRevisionRouteEnhancer @group entity

Namespace

Drupal\Tests\Unit\RouteEnhancer

Code

public function testEnhanceWithEntityRevision() {
  $route = new Route('/test-path/{entity_test_revision}', [], [], [
    'parameters' => [
      'entity_test_revision' => [
        'type' => 'entity_revision:entity_test',
      ],
    ],
  ]);
  $request = Request::create('/test-path/123');
  $entity = $this
    ->prophesize(EntityInterface::class);
  $defaults = [];
  $defaults['entity_test_revision'] = $entity
    ->reveal();
  $defaults[RouteObjectInterface::ROUTE_OBJECT] = $route;
  $expected = $defaults;
  $expected['_entity_revision'] = $defaults['entity_test_revision'];
  $this
    ->assertEquals($expected, $this->routeEnhancer
    ->enhance($defaults, $request));
}