/**
  * Converts a Request entity into an array that is batch-friendly.
  *
  * @param FacebookRequest $request The request entity to convert.
  * @param string|null $requestName The name of the request.
  *
  * @return array
  */
 public static function requestEntityToBatchArray(FacebookRequest $request, $requestName = null)
 {
     $compiledHeaders = [];
     $headers = $request->getHeaders();
     foreach ($headers as $name => $value) {
         $compiledHeaders[] = $name . ': ' . $value;
     }
     $batch = ['headers' => $compiledHeaders, 'method' => $request->getMethod(), 'relative_url' => $request->getUrl()];
     $params = $request->getPostParams();
     if ($params) {
         $batch['body'] = http_build_query($params, null, '&');
     }
     if (isset($requestName)) {
         $batch['name'] = $requestName;
     }
     // @TODO Add support for "omit_response_on_success"
     // @TODO Add support for "depends_on"
     // @TODO Add support for "attached_files"
     // @TODO Add support for JSONP with "callback"
     return $batch;
 }
 public function testParamsAreNotOverwritten()
 {
     $app = new FacebookApp('123', 'foo_secret');
     $request = new FacebookRequest($app, $accessToken = 'foo_token', $method = 'GET', $endpoint = '/foo', $params = ['access_token' => 'bar_access_token', 'appsecret_proof' => 'bar_app_secret']);
     $url = $request->getUrl();
     $expectedParams = 'access_token=bar_access_token&appsecret_proof=bar_app_secret';
     $expectedUrl = '/' . FacebookRequest::getDefaultGraphApiVersion() . '/foo?' . $expectedParams;
     $this->assertEquals($expectedUrl, $url);
     $params = $request->getParams();
     $expectedParams = ['access_token' => 'bar_access_token', 'appsecret_proof' => 'bar_app_secret'];
     $this->assertEquals($expectedParams, $params);
 }