generateRouteRequirements example

$request_headers[$key] = $value;
    }

    foreach ($methods as $method) {
      $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.       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));

      $resource_response_subscriber = new ResourceResponseSubscriber(
        $this->prophesize(SerializerInterface::class)->reveal(),
        $this->prophesize(RendererInterface::class)->reveal(),
        $route_match
      );

      $this->assertSame($expected_response_format$resource_response_subscriber->getResponseFormat($route_match$request));
    }
  }
Home | Imprint | This part of the site doesn't use cookies.