Beispiel #1
0
 /**
  * Test the setQuery method.
  *
  * @return  void
  *
  * @since   1.0
  * @covers  Windwalker\Uri\Uri::setQuery
  */
 public function testSetQuery()
 {
     $this->object->setQuery('somevar=somevalue');
     $this->assertThat($this->object->getQuery(), $this->equalTo('somevar=somevalue'));
     $this->object->setQuery('somevar=somevalue&test=true');
     $this->assertThat($this->object->getQuery(), $this->equalTo('somevar=somevalue&test=true'));
     $this->object->setQuery(array('somevar' => 'somevalue', 'test' => 'true'));
     $this->assertThat($this->object->getQuery(), $this->equalTo('somevar=somevalue&test=true'));
 }
 /**
  * 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;
 }