function ContentPreprocessTest::setupCurrentRouteMatch

Same name and namespace 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 <a href="/api/drupal/core%21modules%21content_moderation%21src%21ContentPreprocess.php/class/ContentPreprocess/8.9.x" title="Determines whether a route is the &quot;Latest version&quot; tab of a node." class="local">\Drupal\content_moderation\ContentPreprocess</a>

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.