[DomCrawler] Exposed getter for baseHref

This commit is contained in:
aa 2016-03-12 20:13:41 +01:00 committed by Fabien Potencier
parent eb2a4f5f7a
commit 53935df0ae
2 changed files with 17 additions and 0 deletions

View File

@ -72,6 +72,16 @@ class Crawler implements \Countable, \IteratorAggregate
$this->add($node);
}
/**
* Returns base href.
*
* @return string
*/
public function getBaseHref()
{
return $this->baseHref;
}
/**
* Removes all the nodes.
*/

View File

@ -27,6 +27,13 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $crawler, '__construct() takes a node as a first argument');
}
public function testGetBaseHref()
{
$baseHref = 'http://symfony.com';
$crawler = new Crawler(null, null, $baseHref);
$this->assertEquals($baseHref, $crawler->getBaseHref());
}
public function testAdd()
{
$crawler = new Crawler();