Exemplo n.º 1
0
 /**
  * @param  array  $data
  * @return ServerRequest
  */
 public function getRequest(array $data = [])
 {
     $method = $this->getMethod();
     $uri = new Uri($this->getAction());
     $body = null;
     if ($this->isGet()) {
         foreach ($this->getData($data) as $key => $value) {
             $uri = Uri::withQueryValue($uri, $key, $value);
         }
     } elseif ($this->isMultipart()) {
         $body = new MultipartStream($this->getMultipartData($data), $this->getMultipartBoundary());
     } else {
         $body = http_build_query($this->getData($data), null, '&');
     }
     $request = new ServerRequest($method, $uri, $this->getHeaders(), $body);
     $files = $this->getFiles();
     return $request->withParsedBody(self::toNestedParams($this->getData($data)))->withAttribute('FILES', $files)->withUploadedFiles(ServerRequest::normalizeFiles($files));
 }
Exemplo n.º 2
0
 public function testNormalizeFilesRaisesException()
 {
     $this->setExpectedException('InvalidArgumentException', 'Invalid value in files specification');
     ServerRequest::normalizeFiles(['test' => 'something']);
 }