From baebdb4b6962f7d541863f213370989522f34564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 15 Mar 2016 23:05:44 +0100 Subject: [PATCH] [DomCrawler] Exposed getter for uri --- src/Symfony/Component/DomCrawler/Crawler.php | 10 ++++++++++ src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 8fe4c1a6a6..2b9d1328be 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -70,6 +70,16 @@ class Crawler implements \Countable, \IteratorAggregate $this->add($node); } + /** + * Returns the current URI. + * + * @return string + */ + public function getUri() + { + return $this->uri; + } + /** * Returns base href. * diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 244b7bf84e..b54563b7c6 100755 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -27,6 +27,13 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase $this->assertCount(1, $crawler, '__construct() takes a node as a first argument'); } + public function testGetUri() + { + $uri = 'http://symfony.com'; + $crawler = new Crawler(null, $uri); + $this->assertEquals($uri, $crawler->getUri()); + } + public function testGetBaseHref() { $baseHref = 'http://symfony.com';