當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Link::getNode方法代碼示例

本文整理匯總了PHP中Symfony\Component\DomCrawler\Link::getNode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Link::getNode方法的具體用法?PHP Link::getNode怎麽用?PHP Link::getNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DomCrawler\Link的用法示例。


在下文中一共展示了Link::getNode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetNode

 public function testGetNode()
 {
     $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($node, $link->getNode(), '->getNode() returns the node associated with the link');
 }
開發者ID:mawaha,項目名稱:tracker,代碼行數:8,代碼來源:LinkTest.php

示例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());
 }
開發者ID:notbrain,項目名稱:symfony,代碼行數:44,代碼來源:LinkTest.php


注:本文中的Symfony\Component\DomCrawler\Link::getNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。