feature #18143 [DomCrawler] Exposed getter for baseHref (AAstakhov)

This PR was squashed before being merged into the 3.1-dev branch (closes #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 | #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
This commit is contained in:
Fabien Potencier 2016-03-15 14:46:52 +01:00
commit b6297104c1
2 changed files with 17 additions and 0 deletions

View File

@ -70,6 +70,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();