ebd020fc74b8ba4d8305bea196e437b7c0721ba7
[m6w6/ext-http] / phpunit / UrlTest.php
1 <?php
2
3 class UrlTest extends PHPUnit_Framework_TestCase {
4 protected $url;
5 function setUp() {
6 $this->url = "http://user:pass@www.example.com:8080/path/file.ext".
7 "?foo=bar&more[]=1&more[]=2#hash";
8 }
9
10 function testStandard() {
11 $this->assertEquals($this->url, (string) new http\Url($this->url));
12
13 $url = new http\Url($this->url,
14 array("path" => "changed", "query" => "foo=&added=this"),
15 http\Url::JOIN_PATH |
16 http\Url::JOIN_QUERY |
17 http\Url::STRIP_AUTH |
18 http\Url::STRIP_FRAGMENT
19 );
20
21 $this->assertEquals("http", $url->scheme);
22 $this->assertEmpty($url->user);
23 $this->assertEmpty($url->pass);
24 $this->assertEquals("www.example.com", $url->host);
25 $this->assertEquals(8080, $url->port);
26 $this->assertEquals("/path/changed", $url->path);
27 $this->assertEquals("foo=&more%5B0%5D=1&more%5B1%5D=2&added=this", $url->query);
28 $this->assertEmpty($url->fragment);
29 }
30 }