3 class UrlTest
extends PHPUnit_Framework_TestCase
{
6 $this->url
= "http://user:pass@www.example.com:8080/path/file.ext".
7 "?foo=bar&more[]=1&more[]=2#hash";
10 function testStandard() {
11 $this->assertEquals($this->url
, (string) new http\
Url($this->url
));
13 $url = new http\
Url($this->url
,
14 array("path" => "changed", "query" => "foo=&added=this"),
16 http\Url
::JOIN_QUERY |
17 http\Url
::STRIP_AUTH |
18 http\Url
::STRIP_FRAGMENT
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("more%5B0%5D=1&more%5B1%5D=2&added=this", $url->query
);
28 $this->assertEmpty($url->fragment
);
32 $tmp = new http\
Url($this->url
);
33 $mod = $tmp->mod(array("query" => "set=1"), http\Url
::REPLACE
);
34 $this->assertNotEquals($tmp->toArray(), $mod->toArray());
35 $this->assertEquals("set=1", $mod->query
);
36 $this->assertEquals("new_fragment", $tmp->mod("#new_fragment")->fragment
);
39 function testStrings() {
40 $url = new http\
Url($this->url
);
41 $this->assertEquals((string) $url, (string) new http\
Url((string) $url));
44 function testArrays() {
45 $url = new http\
Url($this->url
);
46 $this->assertEquals($url->toArray(), (new http\
Url($url->toArray()))->toArray());