示例#1
0
 public function testReadmeExamples()
 {
     $url = new Url();
     $url->setScheme('https://')->setHost('www.reddit.com')->setPath('/r/programming');
     $this->assertEquals('https://www.reddit.com/r/programming', (string) $url);
     $url = new Url('http://example.com?x=0&a=1&b=2');
     $this->assertEquals(array('a' => 1, 'b' => 2, 'x' => 0), $url->getQuery());
     $this->assertEquals('a=1&b=2&x=0', $url->getQueryStr());
     $url = new Url('http://example.com');
     $this->assertEquals('http://example.com', (string) $url);
     $url = new Url('http://example.com/');
     $this->assertEquals('http://example.com/', (string) $url);
     $url = new Url('http://example.com');
     $url->setPath('/');
     $this->assertEquals('http://example.com/', (string) $url);
 }