Beispiel #1
0
 public function testConstructorAndGetters()
 {
     // Test data
     $params_get = array('get');
     $params_post = array('post');
     $cookies = array('cookies');
     $server = array('server');
     $files = array('files');
     $body = 'body';
     // Create the request
     $request = new Request($params_get, $params_post, $cookies, $server, $files, $body);
     // Make sure our data's the same
     $this->assertSame($params_get, $request->paramsGet()->all());
     $this->assertSame($params_post, $request->paramsPost()->all());
     $this->assertSame($cookies, $request->cookies()->all());
     $this->assertSame($server, $request->server()->all());
     $this->assertSame($files, $request->files()->all());
     $this->assertSame($body, $request->body());
 }
 /**
  * Create a new mock request
  *
  * @param string $uri
  * @param string $req_method
  * @param array $parameters
  * @param array $cookies
  * @param array $server
  * @param array $files
  * @param string $body
  * @return void
  */
 public static function create($uri = '/', $req_method = 'GET', $parameters = array(), $cookies = array(), $server = array(), $files = array(), $body = null)
 {
     // Create a new Request object
     $request = new Request(array(), array(), $cookies, $server, $files, $body);
     // Reformat
     $req_method = strtoupper(trim($req_method));
     // Set its URI and Method
     $request->server()->set('REQUEST_URI', $uri);
     $request->server()->set('REQUEST_METHOD', $req_method);
     // Set our parameters
     switch ($req_method) {
         case 'POST':
         case 'PUT':
         case 'PATCH':
         case 'DELETE':
             $request->paramsPost()->replace($parameters);
             break;
         default:
             $request->paramsGet()->replace($parameters);
             break;
     }
     return $request;
 }