/** * Checks if a complete URI with all parts is transformed into an object correctly. * * @test */ public function constructorParsesAFullBlownUriStringCorrectly() { $uriString = 'http://*****:*****@subdomain.domain.com:8080/path1/path2/index.php?argument1=value1&argument2=value2&argument3[subargument1]=subvalue1#anchor'; $uri = new Uri($uriString); $check = $uri->getScheme() == 'http' && $uri->getUsername() == 'username' && $uri->getPassword() == 'password' && $uri->getHost() == 'subdomain.domain.com' && $uri->getPort() === 8080 && $uri->getPath() == '/path1/path2/index.php' && $uri->getQuery() == 'argument1=value1&argument2=value2&argument3[subargument1]=subvalue1' && $uri->getArguments() == ['argument1' => 'value1', 'argument2' => 'value2', 'argument3' => ['subargument1' => 'subvalue1']] && $uri->getFragment() == 'anchor'; $this->assertTrue($check, 'The valid and complete URI has not been correctly transformed to an URI object'); }
/** * Return the Request-Line of this Request Message, consisting of the method, the uri and the HTTP version * Would be, for example, "GET /foo?bar=baz HTTP/1.1" * Note that the URI part is, at the moment, only possible in the form "abs_path" since the * actual requestUri of the Request cannot be determined during the creation of the Request. * * @return string * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1 * @api */ public function getRequestLine() { $requestUri = $this->uri->getPath() . ($this->uri->getQuery() ? '?' . $this->uri->getQuery() : '') . ($this->uri->getFragment() ? '#' . $this->uri->getFragment() : ''); return sprintf("%s %s %s\r\n", $this->method, $requestUri, $this->version); }