[DomCrawler] Added support for link tags in the Link class
This commit is contained in:
parent
e7067cb771
commit
d8d6fcff7d
@ -12,7 +12,7 @@
|
||||
namespace Symfony\Component\DomCrawler;
|
||||
|
||||
/**
|
||||
* Link represents an HTML link (an HTML a or area tag).
|
||||
* Link represents an HTML link (an HTML a, area or link tag).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
@ -179,8 +179,8 @@ class Link
|
||||
*/
|
||||
protected function setNode(\DOMElement $node)
|
||||
{
|
||||
if ('a' !== $node->nodeName && 'area' !== $node->nodeName) {
|
||||
throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName));
|
||||
if ('a' !== $node->nodeName && 'area' !== $node->nodeName && 'link' !== $node->nodeName) {
|
||||
throw new \LogicException(sprintf('Unable to navigate from a "%s" tag.', $node->nodeName));
|
||||
}
|
||||
|
||||
$this->node = $node;
|
||||
|
@ -86,6 +86,18 @@ class LinkTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected, $link->getUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getGetUriTests
|
||||
*/
|
||||
public function testGetUriOnLink($url, $currentUri, $expected)
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML(sprintf('<html><head><link href="%s" /></head></html>', $url));
|
||||
$link = new Link($dom->getElementsByTagName('link')->item(0), $currentUri);
|
||||
|
||||
$this->assertEquals($expected, $link->getUri());
|
||||
}
|
||||
|
||||
public function getGetUriTests()
|
||||
{
|
||||
return array(
|
||||
|
Reference in New Issue
Block a user