* * 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:----UEEyGU/H4poEvBn1s23IMN06yRu6bdednjXA2h7et9WhdyJexJNEgExfzHBkF16cioNSyMWGKs9JIO2fFtKlPCnziRz+nnYxDUJiuo7tAW6wQmRVaG6tcFKNc9UX0FGxBTbcRVyvdMYfIrd86wBXb18mEC7sfu6bh+33sLMDEeGqYPgF2GAw7VUizqNA/Y07sbzUJf0+EdwPgUWYOFobs7Knkytu9xKaKXMpwwQBzf1GHM2DauahIvJ3BWmZSY+fDjL1DoU6+NzuLbYE4GPGRGdIJ80cxxl4R26tP3N+VZbj32L7aDsAlp++0pZ9epgPX93zOVCtM9cTmvvOpP/UfVdPNVBZKRtdi70YGKMvRp0QDRCFjo+gHfXRjrhkTE/8iVQhKHRStkaiPX9amL0134s9lioWnqWnXwlsgKsQd5MQEJrGd1AFqk7bcou7729bm9i5/JjkpzE0+UbR5tWb6OYtD8h3ZL8ojg/ZXsw/j88ATWS7ajTqg/MFm55IqVVY89H4HJ4o7mm3R/Hpo2DPfxiju4PmWOeSDeb2zt6bH2hpG48yp85Az5H1Qk9nh6yuObfsEcu04EC14/lJp2CrKZNm5FiO3Egy8NbqRhGyvGusOKZtzcdLKcEvxZ0PNvWPqf66+onf2FnxNncpXTNcZadY6uZy/CRHG4pGyg2EgZk=----ATTACHMENT:----Mjk5NTAwMTE5MTU0MDcxMiAxNjU2MzMxODMzMzAyNzU0IDk2NjExNzI3OTU3MTAyMjc=