function CurrentRouteMatchTest::getRouteMatch

Same name 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()

Overrides RouteMatchTestBase::getRouteMatch

File

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

Class

CurrentRouteMatchTest
@coversDefaultClass \Drupal\Core\Routing\CurrentRouteMatch @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.