function RouteCachingQueryAlteredTest::testRouteCollectionCacheAfterException
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Routing/RouteCachingQueryAlteredTest.php \Drupal\FunctionalTests\Routing\RouteCachingQueryAlteredTest::testRouteCollectionCacheAfterException()
Tests route collection cache after an exception.
File
-
core/
tests/ Drupal/ FunctionalTests/ Routing/ RouteCachingQueryAlteredTest.php, line 50
Class
- RouteCachingQueryAlteredTest
- Tests the route cache when the request's query parameters are altered.
Namespace
Drupal\FunctionalTests\RoutingCode
public function testRouteCollectionCacheAfterException() : void {
// Force an exception early in the Kernel middleware on a cold cache by
// simulating bad Bearer authentication.
$this->drupalGet('/router-test/rejects-query-strings', [], [
'Authorization' => 'Bearer invalid',
]);
$this->assertSession()
->statusCodeEquals(Response::HTTP_UNAUTHORIZED);
// Check that the route collection cache does not recover any unexpected
// query strings from the earlier request that involved an exception.
// The requested controller returns 400 if there are any query parameters
// present, similar to JSON:API paths that strictly filter requests.
$this->drupalGet('/router-test/rejects-query-strings', [], [
'Authorization' => 'Bearer valid',
]);
$this->assertSession()
->statusCodeEquals(Response::HTTP_OK);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.