diff --git a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php index 9d7737d..5cf2953 100644 --- a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php +++ b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php @@ -89,7 +89,9 @@ public function testResponseFormat($methods, array $supported_formats, $request_ $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); + if ($request_format) { + $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' => $this->randomMachineName()], [$route_requirement_key_format => implode('|', $supported_formats)])); @@ -124,7 +126,9 @@ public function testOnResponseWithCacheableResponse($methods, array $supported_f $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); + if ($request_format) { + $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)])); @@ -172,7 +176,9 @@ public function testOnResponseWithUncacheableResponse($methods, array $supported $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); + if ($request_format) { + $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)]));