Beispiel #1
0
 public function testInit()
 {
     $url = new \webignition\Url\Url();
     $url->init('http://example.com/foo/bar.html?foo=bar&foobar=boofar#identity');
     $this->assertTrue($url->hasScheme());
     $this->assertEquals('http', $url->getScheme());
     $this->assertTrue($url->hasHost());
     $this->assertEquals('example.com', $url->getHost());
     $this->assertTrue($url->hasPath());
     $this->assertEquals('/foo/bar.html', $url->getPath());
     $this->assertTrue($url->hasQuery());
     $this->assertEquals('foo=bar&foobar=boofar', (string) $url->getQuery());
     $this->assertTrue($url->hasFragment());
     $this->assertEquals('identity', $url->getFragment());
 }
Beispiel #2
0
 public function testSetFragmentWithHash()
 {
     $url = new \webignition\Url\Url('http://example.com/');
     $url->setFragment('#fragment');
     $this->assertEquals('fragment', $url->getFragment());
     $this->assertEquals('http://example.com/#fragment', (string) $url);
 }
Beispiel #3
0
 /**
  * When setting a fragment to null in a url that had a fragment
  * and then setting the query to null where there was no query
  * was resulting in the fragment containing the string '?', this is incorrect
  */
 public function testReplaceFragmentWithNullSetNullQuery()
 {
     $url = new \webignition\Url\Url('http://example.com/#fragment');
     $url->setFragment(null);
     $url->setQuery(null);
     $this->assertNull($url->getFragment());
     $this->assertNull($url->getQuery());
     $this->assertEquals("http://example.com/", (string) $url);
 }
Beispiel #4
0
 public function testRelativeUrl()
 {
     $url = new \webignition\Url\Url($this->urls['relative']);
     $this->assertFalse($url->hasScheme());
     $this->assertNull($url->getScheme());
     $this->assertFalse($url->hasHost());
     $this->assertNull($url->getHost());
     $this->assertFalse($url->hasPort());
     $this->assertNull($url->getPort());
     $this->assertFalse($url->hasUser());
     $this->assertNull($url->getUser());
     $this->assertFalse($url->hasPass());
     $this->assertNull($url->getPass());
     $this->assertTrue($url->hasPath());
     $this->assertEquals($this->completePath(), $url->getPath());
     $this->assertTrue($url->hasQuery());
     $this->assertEquals($this->completeUrlQueryString(), $url->getQuery());
     $this->assertTrue($url->hasFragment());
     $this->assertEquals(self::FRAGMENT, $url->getFragment());
     $this->assertEquals($this->urls['relative'], (string) $url);
 }