withStatus example



    /** * @dataProvider withersDataProvider * * @param array<string, mixed> $values */
    public function testWithers(array $values)
    {
        $context = $this->contextBuilder
            ->withInstance($values[ConstraintViolationListNormalizer::INSTANCE])
            ->withStatus($values[ConstraintViolationListNormalizer::STATUS])
            ->withTitle($values[ConstraintViolationListNormalizer::TITLE])
            ->withType($values[ConstraintViolationListNormalizer::TYPE])
            ->withPayloadFields($values[ConstraintViolationListNormalizer::PAYLOAD_FIELDS])
            ->toArray();

        $this->assertSame($values$context);
    }

    /** * @return iterable<array{0: array<string, mixed>}> */
    
public function serverRequestAction(ServerRequestInterface $request): ResponseInterface
    {
        return $this->responseFactory
            ->createResponse()
            ->withBody($this->streamFactory->createStream(sprintf('<html><body>%s</body></html>', $request->getMethod())));
    }

    public function requestAction(RequestInterface $request): ResponseInterface
    {
        return $this->responseFactory
            ->createResponse()
            ->withStatus(403)
            ->withBody($this->streamFactory->createStream(sprintf('<html><body>%s %s</body></html>', $request->getMethod()$request->getBody()->getContents())));
    }

    public function messageAction(MessageInterface $request): ResponseInterface
    {
        return $this->responseFactory
            ->createResponse()
            ->withStatus(422)
            ->withBody($this->streamFactory->createStream(sprintf('<html><body>%s</body></html>', $request->getHeader('X-My-Header')[0])));
    }
}
Home | Imprint | This part of the site doesn't use cookies.