Symfony\Component\HttpFoundation\Request::initialize PHP Method

initialize() public method

This method also re-initializes all properties.
public initialize ( array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], string | resource $content = null )
$query array The GET parameters
$request array The POST parameters
$attributes array The request attributes (parameters parsed from the PATH_INFO, ...)
$cookies array The COOKIE parameters
$files array The FILES parameters
$server array The SERVER parameters
$content string | resource The raw body data
    public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
    {
        $this->request = new ParameterBag($request);
        $this->query = new ParameterBag($query);
        $this->attributes = new ParameterBag($attributes);
        $this->cookies = new ParameterBag($cookies);
        $this->files = new FileBag($files);
        $this->server = new ServerBag($server);
        $this->headers = new HeaderBag($this->server->getHeaders());

        $this->content = $content;
        $this->languages = null;
        $this->charsets = null;
        $this->encodings = null;
        $this->acceptableContentTypes = null;
        $this->pathInfo = null;
        $this->requestUri = null;
        $this->baseUrl = null;
        $this->basePath = null;
        $this->method = null;
        $this->format = null;
    }

Usage Example

 public function testGetDataWithContentTypeJsonWithInvalidSha()
 {
     $this->mockRequest->initialize(['test' => 1], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json', 'HTTP_QUICKPAY_CHECKSUM_SHA256' => '83ce13dffa6523334daa14f33d1fc2adc98ff8b57c4df5be5d2f58b1c2c78fa1e'], '[]');
     try {
         $this->request->getData();
         $this->fail('Expected an exception');
     } catch (InvalidResponseException $e) {
         $this->assertEquals('Invalid response from payment gateway', $e->getMessage());
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::initialize