You are here

public function RequestSanitizerTest::testAcceptableDestinationPost in Drupal 8

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

Tests acceptable destinations are not removed from POST requests.

@dataProvider providerTestAcceptableDestinations

Parameters

string $destination: The destination string to test.

File

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

Class

RequestSanitizerTest
Tests RequestSanitizer class.

Namespace

Drupal\Tests\Core\Security

Code

public function testAcceptableDestinationPost($destination) {

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