Skip to content

Commit 53935df

Browse files
a-astfabpot
authored andcommitted
[DomCrawler] Exposed getter for baseHref
1 parent eb2a4f5 commit 53935df

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ public function __construct($node = null, $currentUri = null, $baseHref = null)
7272
$this->add($node);
7373
}
7474

75+
/**
76+
* Returns base href.
77+
*
78+
* @return string
79+
*/
80+
public function getBaseHref()
81+
{
82+
return $this->baseHref;
83+
}
84+
7585
/**
7686
* Removes all the nodes.
7787
*/

src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public function testConstructor()
2727
$this->assertCount(1, $crawler, '__construct() takes a node as a first argument');
2828
}
2929

30+
public function testGetBaseHref()
31+
{
32+
$baseHref = 'http://symfony.com';
33+
$crawler = new Crawler(null, null, $baseHref);
34+
$this->assertEquals($baseHref, $crawler->getBaseHref());
35+
}
36+
3037
public function testAdd()
3138
{
3239
$crawler = new Crawler();

0 commit comments

Comments
 (0)