diff --git a/tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php b/tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php index ba76252937..e795b5d9a4 100644 --- a/tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php +++ b/tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php @@ -299,6 +299,9 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase $crawler = $this->createTestCrawler('http://example.com/bar')->selectLink('Foo'); $this->assertEquals('http://example.com/foo', $crawler->link()->getUri(), '->link() returns a Link instance'); + $crawler = $this->createTestCrawler('http://example.com/bar')->selectLink('GetLink'); + $this->assertEquals('http://example.com/bar?get=param', $crawler->link()->getUri(), '->link() returns a Link instance'); + try { $this->createTestCrawler()->filter('ol')->link(); $this->fail('->link() throws an \InvalidArgumentException if the node list is empty'); @@ -475,6 +478,8 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase Fabien"s Bar \' Fabien"s Bar + GetLink +
diff --git a/tests/Symfony/Tests/Component/DomCrawler/FormTest.php b/tests/Symfony/Tests/Component/DomCrawler/FormTest.php index c995c36388..eb0d8c129c 100644 --- a/tests/Symfony/Tests/Component/DomCrawler/FormTest.php +++ b/tests/Symfony/Tests/Component/DomCrawler/FormTest.php @@ -280,6 +280,14 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/foo', $form->getUri(true), '->getUri() returns absolute URIs only if the host has been defined in the constructor'); } + public function testGetUriWithOnlyQueryString() + { + $form = $this->createForm('
', null, 'http://localhost', '/foo/bar'); + $this->assertEquals('http://localhost/foo/bar?get=param', $form->getUri(true), '->getUri() returns absolute URIs only if the host has been defined in the constructor'); + + $this->assertEquals('/foo/bar?get=param', $form->getUri(false), '->getUri() returns absolute URIs only if the host has been defined in the constructor'); + } + public function provideGetUriValues() { return array( diff --git a/tests/Symfony/Tests/Component/DomCrawler/LinkTest.php b/tests/Symfony/Tests/Component/DomCrawler/LinkTest.php index add35e04e6..bf3fda2c25 100644 --- a/tests/Symfony/Tests/Component/DomCrawler/LinkTest.php +++ b/tests/Symfony/Tests/Component/DomCrawler/LinkTest.php @@ -72,5 +72,15 @@ class LinkTest extends \PHPUnit_Framework_TestCase $link = new Link($node, 'get','http://www.foo.com','/bar/'); $this->assertEquals('http://login.foo.com/foo', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object'); + + $dom = new \DOMDocument(); + $dom->loadHTML('foo'); + $node = $dom->getElementsByTagName('a')->item(0); + + $link = new Link($node, 'get', 'http://www.foo.com', '/foo/bar'); + $this->assertEquals('http://www.foo.com/foo/bar?get=param', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object'); + + $link = new Link($node, 'get', 'http://www.foo.com', '/foo/bar'); + $this->assertEquals('/foo/bar?get=param', $link->getUri(false), '->getUri() returns the relative URI of the link if false is the first argument'); } }