You are here

public function RequestSanitizerTest::testAcceptableDestinationGet in Drupal 9

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

Tests acceptable destinations are not removed from GET requests.

@dataProvider providerTestAcceptableDestinations

Parameters

string $destination: The destination string to test.

File

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

Class

RequestSanitizerTest
Tests RequestSanitizer class.

Namespace

Drupal\Tests\Core\Security

Code

public function testAcceptableDestinationGet($destination) {

  // Set up a GET request.
  $request = $this
    ->createRequestForTesting([
    'destination' => $destination,
  ]);
  $request = RequestSanitizer::sanitize($request, [], TRUE);
  $this
    ->assertSame($destination, $request->query
    ->get('destination', NULL));
  $this
    ->assertNull($request->request
    ->get('destination', NULL));
  $this
    ->assertSame($destination, $_GET['destination']);
  $this
    ->assertSame($destination, $_REQUEST['destination']);
  $this
    ->assertArrayNotHasKey('destination', $_POST);
  $this
    ->assertEquals([], $this->errors);
}