// \Drupal\Core\StackMiddleware\NegotiationMiddleware normally takes care
// of this so we'll hard code it here.
if ($request_format) { $request->
setRequestFormat($request_format);
} $route_requirements =
$this->
generateRouteRequirements($supported_response_formats,
$supported_request_formats);
$route_match =
new RouteMatch('test',
new Route('/rest/test',
['_rest_resource_config' =>
$this->
randomMachineName()],
$route_requirements));
// The RequestHandler must return a ResourceResponseInterface object.
$handler_response =
new ModifiedResourceResponse(['REST' => 'Drupal'
]);
$this->
assertInstanceOf(ResourceResponseInterface::
class,
$handler_response);
$this->
assertNotInstanceOf(CacheableResponseInterface::
class,
$handler_response);
// The ResourceResponseSubscriber must then generate a response body and
// transform it to a plain Response object.
$resource_response_subscriber =
$this->
getFunctioningResourceResponseSubscriber($route_match);
$event =
new ResponseEvent( $this->
prophesize(HttpKernelInterface::
class)->
reveal(),
$request,
HttpKernelInterface::MAIN_REQUEST,
$handler_response );