ApiPlatform\Core\Tests\EventListener\AddFormatListenerTest::testSupportedAcceptHeader PHP Method

testSupportedAcceptHeader() public method

    public function testSupportedAcceptHeader()
    {
        $request = new Request([], [], ['_api_resource_class' => 'Foo']);
        $request->headers->set('Accept', 'text/html, application/xhtml+xml, application/xml, application/json;q=0.9, */*;q=0.8');
        $eventProphecy = $this->prophesize(GetResponseEvent::class);
        $eventProphecy->getRequest()->willReturn($request)->shouldBeCalled();
        $event = $eventProphecy->reveal();
        $listener = new AddFormatListener(new Negotiator(), ['binary' => ['application/octet-stream'], 'json' => ['application/json']]);
        $listener->onKernelRequest($event);
        $this->assertSame('json', $request->getRequestFormat());
    }