本文整理匯總了PHP中Symfony\Component\Routing\RequestContext::method方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestContext::method方法的具體用法?PHP RequestContext::method怎麽用?PHP RequestContext::method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Routing\RequestContext
的用法示例。
在下文中一共展示了RequestContext::method方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testProducedLinks
/**
* @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());
}