public function testSetHostSetsValue()
 {
     $url = 'http://example.com/path';
     $uri = new URI($url);
     $expected = 'http://another.com/path';
     $uri->setHost('another.com');
     $this->assertEquals('another.com', $uri->getHost());
     $this->assertEquals($expected, (string) $uri);
 }
 /**
  * Sets up our URI object based on the information we have. This is
  * either provided by the user in the baseURL Config setting, or
  * determined from the environment as needed.
  *
  * @param $protocol
  * @param $baseURL
  */
 protected function detectURI($protocol, $baseURL)
 {
     $this->uri->setPath($this->detectPath($protocol));
     // Based on our baseURL provided by the developer (if set)
     // set our current domain name, scheme
     if (!empty($baseURL)) {
         $this->uri->setScheme(parse_url($baseURL, PHP_URL_SCHEME));
         $this->uri->setHost(parse_url($baseURL, PHP_URL_HOST));
         $this->uri->setPort(parse_url($baseURL, PHP_URL_PORT));
     } else {
         $this->isSecure() ? $this->uri->setScheme('https') : $this->uri->setScheme('http');
         // While both SERVER_NAME and HTTP_HOST are open to security issues,
         // if we have to choose, we will go with the server-controlled version first.
         !empty($_SERVER['SERVER_NAME']) ? isset($_SERVER['SERVER_NAME']) ? $this->uri->setHost($_SERVER['SERVER_NAME']) : null : (isset($_SERVER['HTTP_HOST']) ? $this->uri->setHost($_SERVER['HTTP_HOST']) : null);
         if (!empty($_SERVER['SERVER_PORT'])) {
             $this->uri->setPort($_SERVER['SERVER_PORT']);
         }
     }
 }