You are here

protected function RequestSanitizerTest::createRequestForTesting in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php \Drupal\Tests\Core\Security\RequestSanitizerTest::createRequestForTesting()
  2. 9 core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php \Drupal\Tests\Core\Security\RequestSanitizerTest::createRequestForTesting()

Creates a request and sets PHP globals for testing.

Parameters

array $query: (optional) The GET parameters.

array $request: (optional) The POST parameters.

Return value

\Symfony\Component\HttpFoundation\Request The request object.

4 calls to RequestSanitizerTest::createRequestForTesting()
RequestSanitizerTest::testAcceptableDestinationGet in core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
Tests acceptable destinations are not removed from GET requests.
RequestSanitizerTest::testAcceptableDestinationPost in core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
Tests acceptable destinations are not removed from POST requests.
RequestSanitizerTest::testSanitizedDestinationGet in core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
Tests unacceptable destinations are removed from GET requests.
RequestSanitizerTest::testSanitizedDestinationPost in core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
Tests unacceptable destinations are removed from GET requests.

File

core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php, line 299

Class

RequestSanitizerTest
Tests RequestSanitizer class.

Namespace

Drupal\Tests\Core\Security

Code

protected function createRequestForTesting(array $query = [], array $request = []) {
  $request = new Request($query, $request);

  // Set up globals.
  $_GET = $request->query
    ->all();
  $_POST = $request->request
    ->all();
  $_COOKIE = $request->cookies
    ->all();
  $_REQUEST = array_merge($request->query
    ->all(), $request->request
    ->all());
  $request->server
    ->set('QUERY_STRING', http_build_query($request->query
    ->all()));
  $_SERVER['QUERY_STRING'] = $request->server
    ->get('QUERY_STRING');
  return $request;
}