diff --git a/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php b/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php index 17e5aba..93a9789 100644 --- a/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php +++ b/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php @@ -164,11 +164,6 @@ public function providerTestSerialization() { public function testResponseFormat($methods, array $supported_formats, $request_format, array $request_headers, $request_body, $expected_response_content_type, $expected_response_content) { $rest_config_name = $this->randomMachineName(); - $parameters = []; - if ($request_format !== FALSE) { - $parameters['_format'] = $request_format; - } - foreach ($request_headers as $key => $value) { unset($request_headers[$key]); $key = strtoupper(str_replace('-', '_', $key)); @@ -176,7 +171,10 @@ public function testResponseFormat($methods, array $supported_formats, $request_ } foreach ($methods as $method) { - $request = Request::create('/rest/test', $method, $parameters, [], [], $request_headers, $request_body); + $request = Request::create('/rest/test', $method, [], [], [], $request_headers, $request_body); + // \Drupal\Core\StackMiddleware\NegotiationMiddleware normally takes care + // of this so we'll hard code it here. + $request->setRequestFormat($request_format); $route_requirement_key_format = $request->isMethodSafe() ? '_format' : '_content_type_format'; $route_match = new RouteMatch('test', new Route('/rest/test', ['_rest_resource_config' => $rest_config_name], [$route_requirement_key_format => implode('|', $supported_formats)])); diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/DefaultExceptionSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/DefaultExceptionSubscriberTest.php index b10f4fb..61f0cd1 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/DefaultExceptionSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/DefaultExceptionSubscriberTest.php @@ -26,6 +26,8 @@ public function testOnExceptionWithUnknownFormat() { // Format 'bananas' requested, yet only 'json' allowed. $kernel = $this->prophesize(HttpKernelInterface::class); $request = Request::create('/test'); + // \Drupal\Core\StackMiddleware\NegotiationMiddleware normally takes care + // of this so we'll hard code it here. $request->setRequestFormat('bananas'); $e = new MethodNotAllowedHttpException(['json'], 'test message'); $event = new GetResponseForExceptionEvent($kernel->reveal(), $request, 'GET', $e);