Exemplo n.º 1
0
 /**
  * Tests basic parsing.
  * 
  */
 public function testBasicUrlNoPath()
 {
     $url_string = 'http://www.google.com';
     $url = new \Altumo\String\Url($url_string);
     $this->assertTrue($url->isValid(), $url_string);
     $this->assertTrue($url->getScheme() === 'http');
     $this->assertTrue($url->getHost() === 'www.google.com');
     $this->assertTrue($url->hasPath() === false);
     $this->assertTrue($url->hasLogin() === false);
     $this->assertTrue($url->hasPort() === false);
     $this->assertTrue($url->hasAnchor() === false);
     $this->assertTrue($url->hasScheme() === true);
     $this->assertTrue($url->hasHost() === true);
 }
 /**
  * @param string $remote_url
  * 
  * @return string
  * 
  * @throws \Exception if value fails to validate
  */
 protected function assertRemoteUrlValid($remote_url)
 {
     /*
      * Check syntax
      */
     try {
         $url = new \Altumo\String\Url($remote_url);
     } catch (\Exception $e) {
         throw new \Exception('Malformed remote URL.');
     }
     /*
      * check protocol, don't allow ftp or http
      */
     $scheme = $url->getScheme();
     if ($scheme == 'ftp') {
         throw new \Exception('FTP event callbacks are not supported.');
     }
     if ($scheme == 'http') {
         throw new \Exception('HTTP event callbacks are not supported. Please ensure that it is HTTPS for the current URL.');
     }
     return $remote_url;
 }