public function testSetters() { $url = new Url('ftp://www.google.com:8080/foobar?b=2&a=1#easyman'); $this->assertEquals('ftp://www.google.com:8080/foobar?a=1&b=2#easyman', (string) $url); $this->assertFalse($url->isHttps()); $this->assertEquals('ftp', $url->getScheme()); $this->assertEquals('www.google.com', $url->getHost()); $this->assertEquals('com', $url->getTld()); $this->assertEquals(8080, $url->getPort()); $this->assertEquals('/foobar', $url->getPath()); $this->assertEquals(array('a' => 1, 'b' => 2), $url->getQuery()); $this->assertEquals('a=1&b=2', $url->getQueryStr()); $this->assertTrue($url->hasFragment()); $this->assertEquals('easyman', $url->getFragment()); $this->assertEquals(array('easyman' => null), $url->getFragmentQuery()); // modify $url->setScheme('https://')->setHost('reddit.com')->setPort(2001)->setPath('')->setQuery(array())->setFragment(null); $this->assertEquals('https://reddit.com:2001', (string) $url); $url->setPort(443); $this->assertEquals('https://reddit.com', (string) $url); $url->setPort(null); $this->assertEquals('https://reddit.com', (string) $url); $url->setQuery(array('x' => 1, 'y' => 2, 'a' => 3)); $this->assertEquals('https://reddit.com?a=3&x=1&y=2', (string) $url); }