public function testRemove() { $url = new \webignition\Url\Url('http://example.com/?key1=value&key2=value2&key3=value3'); $url->getQuery()->remove('key3'); $this->assertFalse($url->getQuery()->contains('key3')); $this->assertEquals('key1=value&key2=value2', (string) $url->getQuery()); }
public function testSet() { $url = new \webignition\Url\Url('http://example.com/?key1=value&key2=value2'); $url->getQuery()->set('key3', 'value3'); $this->assertTrue($url->getQuery()->contains('key3')); $this->assertEquals('key1=value&key2=value2&key3=value3', (string) $url->getQuery()); $url->getQuery()->set('key4', 'value4'); $this->assertEquals('key1=value&key2=value2&key3=value3&key4=value4', (string) $url->getQuery()); }
public function testChangeQueryWithFragmentWithQuestionMark() { $url = new \webignition\Url\Url('http://example.com/?key1=value1#fragment'); $url->setQuery('?key1=value2'); $this->assertEquals('key1=value2', (string) $url->getQuery()); $this->assertEquals('http://example.com/?key1=value2#fragment', (string) $url); }
public function testMinimalEncodingWithEncodableKeysContainingVerySpecialCharacters() { $query = 'a%23a=1&b%26b=2&c!c=3'; $url = new \webignition\Url\Url('http://example.com/?' . $query); $url->getConfiguration()->disableFullyEncodeQueryStringKeys(); $this->assertEquals($query, (string) $url->getQuery()); }
public function testInit() { $url = new \webignition\Url\Url(); $url->init('http://example.com/foo/bar.html?foo=bar&foobar=boofar#identity'); $this->assertTrue($url->hasScheme()); $this->assertEquals('http', $url->getScheme()); $this->assertTrue($url->hasHost()); $this->assertEquals('example.com', $url->getHost()); $this->assertTrue($url->hasPath()); $this->assertEquals('/foo/bar.html', $url->getPath()); $this->assertTrue($url->hasQuery()); $this->assertEquals('foo=bar&foobar=boofar', (string) $url->getQuery()); $this->assertTrue($url->hasFragment()); $this->assertEquals('identity', $url->getFragment()); }
/** * When setting a fragment to null in a url that had a fragment * and then setting the query to null where there was no query * was resulting in the fragment containing the string '?', this is incorrect */ public function testReplaceFragmentWithNullSetNullQuery() { $url = new \webignition\Url\Url('http://example.com/#fragment'); $url->setFragment(null); $url->setQuery(null); $this->assertNull($url->getFragment()); $this->assertNull($url->getQuery()); $this->assertEquals("http://example.com/", (string) $url); }
public function testRelativeUrl() { $url = new \webignition\Url\Url($this->urls['relative']); $this->assertFalse($url->hasScheme()); $this->assertNull($url->getScheme()); $this->assertFalse($url->hasHost()); $this->assertNull($url->getHost()); $this->assertFalse($url->hasPort()); $this->assertNull($url->getPort()); $this->assertFalse($url->hasUser()); $this->assertNull($url->getUser()); $this->assertFalse($url->hasPass()); $this->assertNull($url->getPass()); $this->assertTrue($url->hasPath()); $this->assertEquals($this->completePath(), $url->getPath()); $this->assertTrue($url->hasQuery()); $this->assertEquals($this->completeUrlQueryString(), $url->getQuery()); $this->assertTrue($url->hasFragment()); $this->assertEquals(self::FRAGMENT, $url->getFragment()); $this->assertEquals($this->urls['relative'], (string) $url); }
public function testQueryContains() { $url = new \webignition\Url\Url('http://example.com/?key1=value&key2=value2'); $this->assertTrue($url->getQuery()->contains('key1')); $this->assertFalse($url->getQuery()->contains('key3')); }