You are here

protected function CurrentRouteMatchTest::getRouteMatch in Drupal 9

Same name and namespace in other branches
  1. 8 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

$name: Route name.

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

array $parameters: Parameters 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 21

Class

CurrentRouteMatchTest
@coversDefaultClass \Drupal\Core\Routing\CurrentRouteMatch @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

protected function getRouteMatch($name, Route $route, array $parameters, array $raw_parameters) {
  $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 ParameterBag($raw_parameters));
  return new CurrentRouteMatch($request_stack);
}