function ContentPreprocessTest::setupCurrentRouteMatch

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php \Drupal\Tests\content_moderation\Unit\ContentPreprocessTest::setupCurrentRouteMatch()
  2. 10 core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php \Drupal\Tests\content_moderation\Unit\ContentPreprocessTest::setupCurrentRouteMatch()
  3. 11.x 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();
}

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