Skip to content

Commit

Permalink
feature #18143 [DomCrawler] Exposed getter for baseHref (AAstakhov)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Mar 15, 2016
2 parents a8591fb + 53935df commit b629710
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Symfony/Component/DomCrawler/Crawler.php
Expand Up @@ -70,6 +70,16 @@ public function __construct($node = null, $currentUri = null, $baseHref = null)
$this->add($node);
}

/**
* Returns base href.
*
* @return string
*/
public function getBaseHref()
{
return $this->baseHref;
}

/**
* Removes all the nodes.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
Expand Up @@ -27,6 +27,13 @@ public function testConstructor()
$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();
Expand Down

0 comments on commit b629710

Please sign in to comment.