diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 8fe4c1a6a60bc..2b9d1328be9c2 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -70,6 +70,16 @@ public function __construct($node = null, $currentUri = null, $baseHref = null) $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 244b7bf84e01f..b54563b7c64fa 100755 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -27,6 +27,13 @@ public function testConstructor() $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';