public function testImportString() { $this->queryString->clear(); $this->queryString->import(''); $this->assertEmpty($this->queryString->toString()); $this->queryString->import($this->string); $arr = array(); parse_str($this->string, $arr); foreach ($arr as $key => $value) { $this->assertTrue($this->queryString->has($key)); $this->assertEquals($value, $this->queryString->get($key)); } }
/** * Convert to a string. * * @return string */ public function toString() { $result = ""; if (!empty($this->scheme)) { $result .= "{$this->scheme}://"; } if (!empty($this->user)) { $result .= !empty($this->pass) ? "{$this->user}:{$this->pass}@" : "{$this->user}@"; } $result .= $this->host; if (!empty($this->port) && (isset($this->portMap[$this->scheme]) && $this->port != $this->portMap[$this->scheme])) { $result .= ":{$this->port}"; } $result .= $this->path; $qs = $this->query->toString(); if (!empty($qs)) { $result .= "?{$qs}"; } if (!empty($this->fragment)) { $result .= "#{$this->fragment}"; } return $result; }