function ContentModerationRouteSubscriberTest::testSetLatestRevisionFlag

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php \Drupal\Tests\content_moderation\Unit\ContentModerationRouteSubscriberTest::testSetLatestRevisionFlag()
  2. 8.9.x core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php \Drupal\Tests\content_moderation\Unit\ContentModerationRouteSubscriberTest::testSetLatestRevisionFlag()
  3. 10 core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php \Drupal\Tests\content_moderation\Unit\ContentModerationRouteSubscriberTest::testSetLatestRevisionFlag()

Tests that the "load_latest_revision" flag is handled correctly.

@covers ::setLatestRevisionFlag

@dataProvider setLatestRevisionFlagTestCases

Parameters

array $defaults: The route defaults.

array $parameters: The route parameters.

array|bool $expected_parameters: (optional) The expected route parameters. Defaults to FALSE.

File

core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php, line 232

Class

ContentModerationRouteSubscriberTest
@coversDefaultClass \Drupal\content_moderation\Routing\ContentModerationRouteSubscriber

Namespace

Drupal\Tests\content_moderation\Unit

Code

public function testSetLatestRevisionFlag($defaults, $parameters, $expected_parameters = FALSE) : void {
    $route = new Route('/foo/{entity_test}', $defaults, [], [
        'parameters' => $parameters,
    ]);
    $route_collection = new RouteCollection();
    $route_collection->add('test', $route);
    $event = new RouteBuildEvent($route_collection);
    $this->routeSubscriber
        ->onAlterRoutes($event);
    // If expected parameters have not been provided, assert they are unchanged.
    $this->assertEquals($expected_parameters ?: $parameters, $route->getOption('parameters'));
}

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