Example #1
0
 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'], []);
 }
Example #2
0
/**
 * 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]);
}
Example #3
0
 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)];
 }
Example #4
0
 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';
 }