ApiPlatform\Core\Tests\Bridge\Symfony\Validator\EventListener\ValidationExceptionListenerTest::testValidationException PHP Method

testValidationException() public method

    public function testValidationException()
    {
        $list = new ConstraintViolationList([]);
        $eventProphecy = $this->prophesize(GetResponseForExceptionEvent::class);
        $eventProphecy->getException()->willReturn(new ValidationException($list))->shouldBeCalled();
        $eventProphecy->getRequest()->willReturn(new Request())->shouldBeCalled();
        $eventProphecy->setResponse(new Response('{"foo": "bar"}', Response::HTTP_BAD_REQUEST, ['Content-Type' => 'application/ld+json; charset=utf-8', 'X-Content-Type-Options' => 'nosniff', 'X-Frame-Options' => 'deny']))->shouldBeCalled();
        $serializerProphecy = $this->prophesize(SerializerInterface::class);
        $serializerProphecy->serialize($list, 'hydra')->willReturn('{"foo": "bar"}')->shouldBeCalled();
        $listener = new ValidationExceptionListener($serializerProphecy->reveal(), ['hydra' => ['application/ld+json']]);
        $listener->onKernelException($eventProphecy->reveal());
    }