You are here

public function ContentModerationRouteSubscriberTest::testSetLatestRevisionFlag in Drupal 9

Same name and namespace in other branches
  1. 8 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 229

Class

ContentModerationRouteSubscriberTest
@coversDefaultClass \Drupal\content_moderation\Routing\ContentModerationRouteSubscriber

Namespace

Drupal\Tests\content_moderation\Unit

Code

public function testSetLatestRevisionFlag($defaults, $parameters, $expected_parameters = FALSE) {
  $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'));
}