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

testAcceptAllHeader() public method

public testAcceptAllHeader ( )
    public function testAcceptAllHeader()
    {
        $request = new Request([], [], ['_api_resource_class' => 'Foo']);
        $request->headers->set('Accept', 'text/html, application/xhtml+xml, application/xml;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('binary', $request->getRequestFormat());
        $this->assertSame('application/octet-stream', $request->getMimeType($request->getRequestFormat()));
    }