/** * Checks if the Route is allowed to be executed. * @param \Brickoo\Component\Routing\Route\HttpRoute $route * @return boolean check result */ private function isAllowedRoute(HttpRoute $route) { return $this->doesPropertyMatch($route->getMethod(), $this->request->getMethod()->toString()) && $this->doesPropertyMatch($route->getHostname(), $this->request->getUri()->getHostname()) && $this->doesPropertyMatch($route->getScheme(), $this->request->getUri()->getScheme()); }
/** @covers Brickoo\Component\Http\HttpRequest::toString */ public function testRequestToString() { $methodString = HttpMethod::GET; $versionString = HttpVersion::HTTP_1_1; $bodyString = "test content"; $headerString = "UNIT: TEST"; $queryString = "key=value1"; $urlPath = "/path/to/script"; $method = $this->getHttpMethodStub(); $method->expects($this->any())->method("toString")->will($this->returnValue($methodString)); $version = $this->getHttpVersionStub(); $version->expects($this->any())->method("toString")->will($this->returnValue($versionString)); $header = $this->getHttpMessageHeaderStub(); $header->expects($this->any())->method("toString")->will($this->returnValue($headerString)); $body = $this->getMock("\\Brickoo\\Component\\Http\\HttpMessageBody"); $body->expects($this->any())->method("getContent")->will($this->returnValue($bodyString)); $message = $this->getHttpMessageStub(); $message->expects($this->any())->method("getHeader")->will($this->returnValue($header)); $message->expects($this->any())->method("getBody")->will($this->returnValue($body)); $query = $this->getMock("\\Brickoo\\Component\\Http\\UriQuery"); $query->expects($this->any())->method("toString")->will($this->returnValue($queryString)); $uri = $this->getHttpUriStub(); $uri->expects($this->any())->method("getQuery")->will($this->returnValue($query)); $uri->expects($this->any())->method("getPath")->will($this->returnValue($urlPath)); $expectedValue = sprintf("%s %s %s\r\n", $methodString, $urlPath . "?" . $queryString, $versionString); $expectedValue .= $headerString . "\r\n\r\n" . $bodyString; $Request = new HttpRequest($method, $version, $uri, $message); $this->assertEquals($expectedValue, $Request->toString()); }