You are here

protected function ContentPreprocessTest::setupCurrentRouteMatch in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php \Drupal\Tests\content_moderation\Unit\ContentPreprocessTest::setupCurrentRouteMatch()

Mock the current route matching object.

Parameters

string $route_name: The route to mock.

int $nid: The node ID for mocking.

Return value

\Drupal\Core\Routing\CurrentRouteMatch The mocked current route match object.

1 call to ContentPreprocessTest::setupCurrentRouteMatch()
ContentPreprocessTest::testIsLatestVersionPage in core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php
@covers ::isLatestVersionPage @dataProvider routeNodeProvider

File

core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php, line 49

Class

ContentPreprocessTest
@coversDefaultClass \Drupal\content_moderation\ContentPreprocess

Namespace

Drupal\Tests\content_moderation\Unit

Code

protected function setupCurrentRouteMatch($route_name, $nid) {
  $route_match = $this
    ->prophesize(CurrentRouteMatch::class);
  $route_match
    ->getRouteName()
    ->willReturn($route_name);
  $route_match
    ->getParameter('node')
    ->willReturn($this
    ->setupNode($nid));
  return $route_match
    ->reveal();
}