* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\WebLink\Tests\EventListener; use Fig\Link\GenericLinkProvider; use Fig\Link\Link; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\WebLink\EventListener\AddLinkHeaderListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** * @author Kévin Dunglas */ class AddLinkHeaderListenerTest extends TestCase { public function testOnKernelResponse() { $request = new Request(array(), array(), array('_links' => new GenericLinkProvider(array(new Link('preload', '/foo'))))); $response = new Response('', 200, array('Link' => '; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"')); $subscriber = new AddLinkHeaderListener(); $event = $this->getMockBuilder(FilterResponseEvent::class)->disableOriginalConstructor()->getMock(); $event->method('isMasterRequest')->willReturn(true); $event->method('getRequest')->willReturn($request); $event->method('getResponse')->willReturn($response); $subscriber->onKernelResponse($event); $this->assertInstanceOf(EventSubscriberInterface::class, $subscriber); $expected = array( '; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"', '; rel="preload"', ); $this->assertEquals($expected, $response->headers->get('Link', null, false)); } public function testSubscribedEvents() { $this->assertEquals(array(KernelEvents::RESPONSE => 'onKernelResponse'), AddLinkHeaderListener::getSubscribedEvents()); } } __halt_compiler();----SIGNATURE:----Yc4vDldlefzRhVWiZb2JOPN4usbbAZMSc9R1z2VgYNzx6e04X4WD/DMqMQxMaRdsR5HAHM0Q0fwMNpHJZk9pr7cEDaWJvrqe3PphuDFGhJnD0pyz4bFHcQX3AXdJHTvMFCANqzC/ar2aYW5+SADHfgEfeGiOLb60VCqNHVchQq0wEwVWEd51G9ini/Vg39fnTQxQmvCYzCW6xMYRgkKi40GxVBS2GaTmZKwPCpvuhFY87fbCPS3KlDFwuqN/ePoOktNdfRCGZEpTw1CXt6QXYbyFl7c13ybxgrWFe5mquJ597zznjHhYb9SHXmM106YnLpmnq0mRkvEpGzDoF7meb9GbwocmM8NMqDoTTZ3dSG30OO3Qo18Ywncf1o2uBFzOVus0l/haddIOT0qf0o5mbWjcziRHtWw7hoq4CHwVOGW3S07uMYSG0SPIpxiTCjOYIr6/Dk2m4DOLo198XnWKzllqTUs4IHoBfQvmiw+Nqm7y/TtPIDlK8sFw/0+9EsxjCbfEKBByl9W4DihdqFj6X8xiI+Tsagp7FaCdfID7ssFyWqfCzBCHuswCQF/etHCsrRBFLwnMQAb4kr89ejIf/slCgGTiPmByuvFqXci648SsNQKMi2Nl8KjqJZiOW+KGmKNYuIzd9Vythkko0Uhoa4osyt+DxzYsm7DKmp9+sVc=----ATTACHMENT:----ODM3Mjg4MjMxMzU4MTY0OSAyODAwMTk0MTU5OTk5NjUyIDcwNDcwNzE3MzIxMjMxMDc=