/**
  * Get system Uri object.
  *
  * @param   string  $requestUri  The request uri string.
  * @param   bool    $refresh     Refresh the uri.
  *
  * @return  Uri  The system Uri object.
  *
  * @since   2.0
  */
 protected function getSystemUri($requestUri = null, $refresh = false)
 {
     if ($this->uri && !$refresh) {
         return $this->uri;
     }
     $requestUri = $requestUri ?: $this->detectRequestUri();
     // Start with the requested URI.
     $uri = new Uri($requestUri);
     // If we are working from a CGI SAPI with the 'cgi.fix_pathinfo' directive disabled we use PHP_SELF.
     if (strpos(php_sapi_name(), 'cgi') !== false && !ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) {
         // We aren't expecting PATH_INFO within PHP_SELF so this should work.
         $uri->setPath(rtrim(dirname($_SERVER['PHP_SELF']), '/\\'));
     } else {
         $uri->setPath(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'));
     }
     // Clear the unused parts of the requested URI.
     $uri->setQuery(null);
     $uri->setFragment(null);
     return $this->uri = $uri;
 }
Esempio n. 2
0
 /**
  * Test the setFragment method.
  *
  * @return  void
  *
  * @since   1.0
  * @covers  Windwalker\Uri\Uri::setFragment
  */
 public function testSetFragment()
 {
     $this->object->setFragment('someFragment');
     $this->assertThat($this->object->getFragment(), $this->equalTo('someFragment'));
 }