public function testChangePath() { $url = new \webignition\Url\Url('http://example.com/path'); $url->setPath('/new-path'); $this->assertEquals('/new-path', $url->getPath()); $this->assertEquals('http://example.com/new-path', (string) $url); }
public function testSetPathWhenExistingPathIsUrlEncoded() { $url = new \webignition\Url\Url('js/scriptaculous.js?load=effects,builder'); $this->assertEquals('js/scriptaculous.js?load=effects%2Cbuilder', (string) $url); $url->setPath('/js/scriptaculous.js'); $this->assertEquals('/js/scriptaculous.js?load=effects%2Cbuilder', (string) $url); }
public function testAddPathToRootUrl() { $url = new \webignition\Url\Url('http://example.com'); $url->setPath('/index.html'); $this->assertEquals('http://example.com/index.html', (string) $url); $url = new \webignition\Url\Url('http://example.com/'); $url->setPath('/index.html'); $this->assertEquals('http://example.com/index.html', (string) $url); }
public function testSetPathThenHostThenSchemeThenUser() { $url = new \webignition\Url\Url('example.php'); $this->assertEquals('example.php', (string) $url); $url->setPath('/pathOne/Path2/path2/example2.php'); $this->assertEquals('/pathOne/Path2/path2/example2.php', (string) $url); $url->setHost('www.example.com'); $this->assertEquals('//www.example.com/pathOne/Path2/path2/example2.php', (string) $url); $url->setScheme('http'); $this->assertEquals('http://www.example.com/pathOne/Path2/path2/example2.php', (string) $url); $url->setUser('user'); $this->assertEquals('http://user:@www.example.com/pathOne/Path2/path2/example2.php', (string) $url); }
public function testReplaceFragmentPassPathPortQueryUserWithNull() { $url = new \webignition\Url\Url('http://*****:*****@example.com:443/path/here?param=value#fragment'); $url->setFragment(null); $url->setPass(null); $url->setPath(null); $url->setPort(null); $url->setQuery(null); $url->setUser(null); $this->assertNull($url->getFragment()); $this->assertNull($url->getPass()); $this->assertNull($url->getPath()); $this->assertNull($url->getPort()); $this->assertNull($url->getQuery()); $this->assertNull($url->getUser()); $this->assertEquals("http://example.com", (string) $url); }
public function testAddPathToHashAndIdentifier() { $url = new \webignition\Url\Url('#foo'); $url->setPath('/index.html'); $this->assertEquals('/index.html#foo', (string) $url); }