function ContentPreprocessTest::setupCurrentRouteMatch

Same name and namespace in other branches
  1. 11.x 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. 9 core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php \Drupal\Tests\content_moderation\Unit\ContentPreprocessTest::setupCurrentRouteMatch()
  4. 8.9.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
Tests is latest version page.

File

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

Class

ContentPreprocessTest
Tests 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.