use Symfony\Component\WebLink\EventListener\AddLinkHeaderListener;
use Symfony\Component\WebLink\GenericLinkProvider;
use Symfony\Component\WebLink\Link;
/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class AddLinkHeaderListenerTest extends TestCase
{ public function testOnKernelResponse() { $request =
new Request([],
[],
['_links' =>
new GenericLinkProvider([new Link('preload', '/foo'
)])]);
$response =
new Response('', 200,
['Link' => '<https://demo.api-platform.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'
]);
$subscriber =
new AddLinkHeaderListener();
$event =
new ResponseEvent($this->
createMock(HttpKernelInterface::
class),
$request, HttpKernelInterface::MAIN_REQUEST,
$response);
$subscriber->
onKernelResponse($event);
$this->
assertInstanceOf(EventSubscriberInterface::
class,
$subscriber);
$expected =
[