Skip to content

Commit b629710

Browse files
committed
feature symfony#18143 [DomCrawler] Exposed getter for baseHref (AAstakhov)
This PR was squashed before being merged into the 3.1-dev branch (closes symfony#18143). Discussion ---------- [DomCrawler] Exposed getter for baseHref | Q | A | ------------- | --- | Branch | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#15584 | License | MIT | Doc PR | n/a I know that PR for this issue already created, but it is Hack Day, so I'm making my first contribution anyway. Commits ------- 53935df [DomCrawler] Exposed getter for baseHref
2 parents a8591fb + 53935df commit b629710

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
@@ -70,6 +70,16 @@ public function __construct($node = null, $currentUri = null, $baseHref = null)
7070
$this->add($node);
7171
}
7272

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

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)