public function testCreateBasic() { $result = Response\create(); $this->assertNotNull($result); $this->assertEquals($result['body'], ''); $this->assertEquals($result['headers'], []); $this->assertEquals($result['status'], 200); $this->assertEquals($result['assigns'], []); }
/** * Processes the request to build a response. * * @param $routes array * @param $options array * @return string */ function run(array $routes, array $options = []) { $paramSet = isset($options['param_set']) ? $options['param_set'] : []; $params = Request\prepareParams($paramSet); $request = Request\parse($params); $response = Response\create(); $pipeline = wrapPipeline($request, $routes, $options); return Util\pipe($pipeline, ['request' => $request, 'response' => $response]); }
protected function setup() { $text = 'basicHandler'; $response = Response\create(); $response['body'] = $text; $this->basicResult = $response; $this->basicPattern = '/test'; $this->basicHandler = function ($conn) use($text) { $conn['response']['body'] = $text; return $conn; }; $this->basicRequest = ['uri' => trim($this->basicPattern, '/'), 'server' => ['REQUEST_METHOD' => 'GET'], 'params' => []]; $this->basicRoutes = [Route\get($this->basicPattern, $this->basicHandler)]; }
protected function setup() { $text = 'basicHandler'; $response = Response\create(); $response['body'] = $text; $this->basicResult = $response; $this->basicPattern = '/test'; $this->basicHandler = function ($conn) use($text) { $conn['response']['body'] = $text; return $conn; }; $this->basicRoutes = [Route\get($this->basicPattern, $this->basicHandler)]; $_SERVER['REQUEST_URI'] = $this->basicPattern; $_SERVER['REQUEST_METHOD'] = 'GET'; }