function RequestSanitizerTest::testRequestMethodOverride
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php \Drupal\Tests\Core\Security\RequestSanitizerTest::testRequestMethodOverride()
Tests HTTP method override handling during request sanitization.
Attributes
#[TestWith([
"POST",
"POST",
])]
#[TestWith([
"GET",
"POST",
])]
#[TestWith([
"HEAD",
"POST",
])]
#[TestWith([
"PUT",
"PUT",
])]
#[TestWith([
"DELETE",
"DELETE",
])]
#[TestWith([
"CONNECT",
"POST",
])]
#[TestWith([
"OPTIONS",
NULL,
])]
#[TestWith([
"QUERY",
NULL,
])]
#[TestWith([
"TRACE",
"POST",
])]
#[TestWith([
"PATCH",
"PATCH",
])]
File
-
core/
tests/ Drupal/ Tests/ Core/ Security/ RequestSanitizerTest.php, line 313
Class
- RequestSanitizerTest
- Tests RequestSanitizer class.
Namespace
Drupal\Tests\Core\SecurityCode
public function testRequestMethodOverride(string $override, ?string $expected) : void {
$request = $this->createRequestForTesting();
$request->server
->set('REQUEST_METHOD', 'POST');
$request->headers
->set('X-HTTP-Method-Override', $override);
if (!$expected) {
$this->expectException(BadRequestHttpException::class);
}
$request = RequestSanitizer::sanitize($request, []);
$this->assertSame($expected, $request->getMethod());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.