function EntityRevisionRouteEnhancerTest::testEnhanceWithEntityRevision

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

@covers ::enhance

File

core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php, line 64

Class

EntityRevisionRouteEnhancerTest
@coversDefaultClass \Drupal\Core\Routing\Enhancer\EntityRevisionRouteEnhancer @group Entity

Namespace

Drupal\Tests\Core\Enhancer

Code

public function testEnhanceWithEntityRevision() : void {
    $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));
}

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