本文整理匯總了PHP中Symfony\Component\DomCrawler\Link::getMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Link::getMethod方法的具體用法?PHP Link::getMethod怎麽用?PHP Link::getMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DomCrawler\Link
的用法示例。
在下文中一共展示了Link::getMethod方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetMethod
public function testGetMethod()
{
$dom = new \DOMDocument();
$dom->loadHTML('<html><a href="/foo">foo</a></html>');
$node = $dom->getElementsByTagName('a')->item(0);
$link = new Link($node, 'http://example.com/');
$this->assertEquals('GET', $link->getMethod(), '->getMethod() returns the method of the link');
$link = new Link($node, 'http://example.com/', 'post');
$this->assertEquals('POST', $link->getMethod(), '->getMethod() returns the method of the link');
}
示例2: testGetters
public function testGetters()
{
$dom = new \DOMDocument();
$dom->loadHTML('<html><a href="/foo">foo</a></html>');
$node = $dom->getElementsByTagName('a')->item(0);
$link = new Link($node);
$this->assertEquals('/foo', $link->getUri(), '->getUri() returns the URI of the link');
$this->assertEquals($node, $link->getNode(), '->getNode() returns the node associated with the link');
$this->assertEquals('get', $link->getMethod(), '->getMethod() returns the method of the link');
$link = new Link($node, 'post');
$this->assertEquals('post', $link->getMethod(), '->getMethod() returns the method of the link');
$link = new Link($node, 'get', 'http://localhost', '/bar/');
$this->assertEquals('http://localhost/foo', $link->getUri(), '->getUri() returns the absolute URI of the link');
$this->assertEquals('/foo', $link->getUri(false), '->getUri() returns the relative URI of the link if false is the first argument');
$dom = new \DOMDocument();
$dom->loadHTML('<html><a href="foo">foo</a></html>');
$node = $dom->getElementsByTagName('a')->item(0);
$link = new Link($node, 'get', 'http://localhost', '/bar/');
$this->assertEquals('http://localhost/bar/foo', $link->getUri(), '->getUri() returns the absolute URI of the link for relative hrefs');
$this->assertEquals('/bar/foo', $link->getUri(false), '->getUri() returns the relative URI of the link if false is the first argument');
$dom = new \DOMDocument();
$dom->loadHTML('<html><a href="http://login.foo.com/foo">foo</a></html>');
$node = $dom->getElementsByTagName('a')->item(0);
$link = new Link($node, 'get', 'http://www.foo.com');
$this->assertEquals('http://login.foo.com/foo', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
$link = new Link($node, 'get');
$this->assertEquals('http://login.foo.com/foo', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
$link = new Link($node, 'get', null, '/bar/');
$this->assertEquals('http://login.foo.com/foo', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
$link = new Link($node, 'get', 'http://www.foo.com', '/bar/');
$this->assertEquals('http://login.foo.com/foo', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
$dom = new \DOMDocument();
$dom->loadHTML('<html><a href="?get=param">foo</a></html>');
$node = $dom->getElementsByTagName('a')->item(0);
$link = new Link($node, 'get', 'http://www.foo.com', '/foo/bar');
$this->assertEquals('http://www.foo.com/foo/bar?get=param', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
$link = new Link($node, 'get', 'http://www.foo.com', '/foo/bar');
$this->assertEquals('/foo/bar?get=param', $link->getUri(false), '->getUri() returns the relative URI of the link if false is the first argument');
$dom = new \DOMDocument();
$dom->loadHTML('<html><a href="test.html">foo</a></html>');
$node = $dom->getElementsByTagName('a')->item(0);
$link = new Link($node, 'get', null, '/foo/bar', 'http://www.foo.com/');
$this->assertEquals('http://www.foo.com/test.html', $link->getUri());
}
示例3: click
/**
* Clicks on a given link.
*
* @param Link $link A Link instance
*/
public function click(Link $link)
{
return $this->request($link->getMethod(), $link->getUri());
}