You are here

public function LanguageTestController::testSubRequest in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::testSubRequest()

Uses a sub request to retrieve the 'user' page.

Return value

\Symfony\Component\HttpFoundation\Response The kernels response to the sub request.

1 string reference to 'LanguageTestController::testSubRequest'
language_test.routing.yml in core/modules/language/tests/language_test/language_test.routing.yml
core/modules/language/tests/language_test/language_test.routing.yml

File

core/modules/language/tests/language_test/src/Controller/LanguageTestController.php, line 122

Class

LanguageTestController
Controller routines for language_test routes.

Namespace

Drupal\language_test\Controller

Code

public function testSubRequest() {
  $request = Request::createFromGlobals();
  $server = $request->server
    ->all();
  if (basename($server['SCRIPT_FILENAME']) != basename($server['SCRIPT_NAME'])) {

    // We need this for when the test is executed by run-tests.sh.
    // @todo Remove this once run-tests.sh has been converted to use a Request
    //   object.
    $server['SCRIPT_FILENAME'] = $server['SCRIPT_NAME'];
    $base_path = ltrim($server['REQUEST_URI'], '/');
  }
  else {
    $base_path = $request
      ->getBasePath();
  }
  $sub_request = Request::create($base_path . '/user', 'GET', $request->query
    ->all(), $request->cookies
    ->all(), [], $server);
  return $this->httpKernel
    ->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
}