function LanguageNegotiationContentEntityTest::setCurrentRequestForRoute

Same name and namespace in other branches
  1. 8.9.x core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php \Drupal\Tests\language\Functional\LanguageNegotiationContentEntityTest::setCurrentRequestForRoute()
  2. 10 core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php \Drupal\Tests\language\Functional\LanguageNegotiationContentEntityTest::setCurrentRequestForRoute()
  3. 11.x core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php \Drupal\Tests\language\Functional\LanguageNegotiationContentEntityTest::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.

1 call to LanguageNegotiationContentEntityTest::setCurrentRequestForRoute()
LanguageNegotiationContentEntityTest::testEnabledLanguageContentNegotiator in core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
Tests enabling the language negotiator language_content_entity.

File

core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php, line 184

Class

LanguageNegotiationContentEntityTest
Tests language negotiation with the language negotiator content entity.

Namespace

Drupal\Tests\language\Functional

Code

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);
}

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