Example #1
0
 public function testWithout()
 {
     $uri = new \Owl\Http\Uri('http://*****:*****@www.example.com:88/p1?a=b&c=d#f');
     $this->assertMethods($uri->withoutScheme(), ['getScheme' => '', '__toString' => '//foo:bar@www.example.com:88/p1?a=b&c=d#f']);
     $this->assertMethods($uri->withoutUserInfo(), ['getAuthority' => 'www.example.com:88', '__toString' => 'http://www.example.com:88/p1?a=b&c=d#f']);
     $this->assertMethods($uri->withoutHost(), ['getHost' => '', '__toString' => '/p1?a=b&c=d#f']);
     $this->assertMethods($uri->withoutPath(), ['getPath' => '/', '__toString' => 'http://*****:*****@www.example.com:88/?a=b&c=d#f']);
     $this->assertMethods($uri->withoutQuery(), ['getQuery' => '', '__toString' => 'http://*****:*****@www.example.com:88/p1#f']);
     $this->assertMethods($uri->withoutQuery(['c']), ['getQuery' => 'a=b', '__toString' => 'http://*****:*****@www.example.com:88/p1?a=b#f']);
     $this->assertMethods($uri->withoutQuery('c'), ['getQuery' => 'a=b', '__toString' => 'http://*****:*****@www.example.com:88/p1?a=b#f']);
     $this->assertMethods($uri->withoutFragment(), ['getFragment' => '', '__toString' => 'http://*****:*****@www.example.com:88/p1?a=b&c=d']);
 }
Example #2
0
 public function testSetter()
 {
     $uri = new \Owl\Http\Uri('http://*****:*****@www.example.com:88/p1?a=b&c=d#f');
     $this->assertMethods($uri->withScheme('https'), ['getScheme' => 'https', '__toString' => 'https://*****:*****@www.example.com:88/p1?a=b&c=d#f']);
     $this->assertMethods($uri->withHost('example.com'), ['getHost' => 'example.com', '__toString' => 'http://*****:*****@example.com:88/p1?a=b&c=d#f']);
     $this->assertMethods($uri->withPort(80), ['getPort' => null, '__toString' => 'http://*****:*****@www.example.com/p1?a=b&c=d#f']);
     $this->assertMethods($uri->withPath('/p2'), ['getPath' => '/p2', '__toString' => 'http://*****:*****@www.example.com:88/p2?a=b&c=d#f']);
     $this->assertMethods($uri->withQuery('x=y'), ['getQuery' => 'x=y', '__toString' => 'http://*****:*****@www.example.com:88/p1?x=y#f']);
     $this->assertMethods($uri->withQuery(['x' => 'y']), ['getQuery' => 'x=y', '__toString' => 'http://*****:*****@www.example.com:88/p1?x=y#f']);
     $this->assertMethods($uri->withQuery(''), ['getQuery' => '', '__toString' => 'http://*****:*****@www.example.com:88/p1#f']);
     $this->assertMethods($uri->withQuery([]), ['getQuery' => '', '__toString' => 'http://*****:*****@www.example.com:88/p1#f']);
     $this->assertMethods($uri->withFragment('fff'), ['getFragment' => 'fff', '__toString' => 'http://*****:*****@www.example.com:88/p1?a=b&c=d#fff']);
     $this->assertMethods($uri->withFragment(''), ['getFragment' => '', '__toString' => 'http://*****:*****@www.example.com:88/p1?a=b&c=d']);
 }