示例#1
0
 public function testChangeScheme()
 {
     $url = new \webignition\Url\Url('http://example.com/');
     $url->setScheme('https');
     $this->assertEquals('https', $url->getScheme());
     $this->assertEquals('https://example.com/', (string) $url);
 }
示例#2
0
 public function testSetSchemeOnProtocolRelativeUrl()
 {
     $url = new \webignition\Url\Url('//example.com');
     $url->setScheme('http');
     $this->assertEquals('http', $url->getScheme());
     $this->assertEquals('http://example.com', (string) $url);
 }
示例#3
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());
 }
示例#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);
 }
示例#5
0
 public function testSetSchemeForUrlThatHasNoHost()
 {
     $url = new \webignition\Url\Url($this->urls['root-relative']);
     $url->setScheme('http');
     $this->assertNull($url->getScheme());
 }
示例#6
0
 public function isValid(Link $link)
 {
     $link = new \webignition\Url\Url($link->getLinkHref());
     return $link->getScheme() === 'http' || $link->getScheme() === 'https' || $link->getHost() !== null;
 }