function CurrentRouteMatchTest::getRouteMatch

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php \Drupal\Tests\Core\Routing\CurrentRouteMatchTest::getRouteMatch()
  2. 8.9.x core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php \Drupal\Tests\Core\Routing\CurrentRouteMatchTest::getRouteMatch()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php \Drupal\Tests\Core\Routing\CurrentRouteMatchTest::getRouteMatch()

Build a test route match object for the given implementation.

Parameters

string $name: Route name.

\Symfony\Component\Routing\Route $route: Request object

array $parameters: Parameters array

array $raw_parameters: Raw parameters array

Return value

\Drupal\Core\Routing\RouteMatchInterface

Overrides RouteMatchTestBase::getRouteMatch

File

core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php, line 25

Class

CurrentRouteMatchTest
@coversDefaultClass \Drupal\Core\Routing\CurrentRouteMatch[[api-linebreak]] @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

protected static function getRouteMatch(string $name, Route $route, array $parameters, array $raw_parameters) : RouteMatchInterface {
  $request_stack = new RequestStack();
  $request = new Request();
  $request_stack->push($request);
  $request = $request_stack->getCurrentRequest();
  $request->attributes = new ParameterBag($parameters);
  $request->attributes
    ->set(RouteObjectInterface::ROUTE_NAME, $name);
  $request->attributes
    ->set(RouteObjectInterface::ROUTE_OBJECT, $route);
  $request->attributes
    ->set('_raw_variables', new InputBag($raw_parameters));
  return new CurrentRouteMatch($request_stack);
}

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