Ejemplo n.º 1
0
 /**
  * @param string $method
  * @dataProvider getLinkMethods
  */
 public function testProducedLinks($method)
 {
     $listener = $this->getListener();
     $event = $this->getEvent();
     $urlParams = ['foo' => 'bar'];
     $this->urlMatcher->expects($this->exactly(3))->method('match')->willReturn($urlParams);
     $event->getRequest()->setMethod($method);
     $event->getRequest()->headers->set('Link', 'link1,link2, link3');
     $this->context->method('getMethod')->willReturn('METHOD');
     $this->context->expects($this->exactly(2))->method('setMethod')->withConsecutive(['GET'], ['METHOD']);
     $listener->onKernelRequest($event);
     $this->assertTrue($event->getRequest()->attributes->has('links'));
     /** @var LinkHeader[] $links */
     $links = $event->getRequest()->attributes->get('links');
     $this->assertEquals(3, count($links));
     $this->assertEquals('link1', $links[0]->getOriginalHeader());
     $this->assertEquals($urlParams, $links[0]->getUrlParameters());
     $this->assertEquals('link2', $links[1]->getOriginalHeader());
     $this->assertEquals('link3', $links[2]->getOriginalHeader());
 }