protected function EntityUrlLanguageTest::setCurrentRequestForRoute in Drupal 10
Same name and namespace in other branches
- 8 core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php \Drupal\Tests\language\Kernel\EntityUrlLanguageTest::setCurrentRequestForRoute()
- 9 core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php \Drupal\Tests\language\Kernel\EntityUrlLanguageTest::setCurrentRequestForRoute()
Sets the current request to a specific path with the corresponding route.
Parameters
string $path: The path for which the current request should be created.
string $route_name: The route name for which the route object for the request should be created.
File
- core/
modules/ language/ tests/ src/ Kernel/ EntityUrlLanguageTest.php, line 128
Class
- EntityUrlLanguageTest
- Tests the language of entity URLs. @group language
Namespace
Drupal\Tests\language\KernelCode
protected function setCurrentRequestForRoute($path, $route_name) {
$request = Request::create($path);
$request->attributes
->set(RouteObjectInterface::ROUTE_NAME, $route_name);
$request->attributes
->set(RouteObjectInterface::ROUTE_OBJECT, new Route($path));
$this->container
->get('request_stack')
->push($request);
}