Skip to content

Commit b7420de

Browse files
committed
Add test for supported Accept header which happens to match a Symfony built-in format
1 parent 2e487c5 commit b7420de

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/EventListener/AddFormatListenerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ public function testSupportedAcceptHeader()
121121
$this->assertSame('json', $request->getRequestFormat());
122122
}
123123

124+
public function testSupportedAcceptHeaderSymfonyBuiltInFormat()
125+
{
126+
$request = new Request([], [], ['_api_resource_class' => 'Foo']);
127+
$request->headers->set('Accept', 'application/json');
128+
129+
$eventProphecy = $this->prophesize(GetResponseEvent::class);
130+
$eventProphecy->getRequest()->willReturn($request);
131+
$event = $eventProphecy->reveal();
132+
133+
$formatsProviderProphecy = $this->prophesize(FormatsProviderInterface::class);
134+
$formatsProviderProphecy->getFormatsFromAttributes([])->willReturn(['jsonld' => ['application/ld+json', 'application/json']]);
135+
136+
$listener = new AddFormatListener(new Negotiator(), $formatsProviderProphecy->reveal());
137+
$listener->onKernelRequest($event);
138+
139+
$this->assertSame('jsonld', $request->getRequestFormat());
140+
}
141+
124142
public function testAcceptAllHeader()
125143
{
126144
$request = new Request([], [], ['_api_resource_class' => 'Foo']);

0 commit comments

Comments
 (0)