summaryrefslogtreecommitdiff
path: root/lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-04-26 01:00:12 +0200
committeremkael <emkael@tlen.pl>2018-04-26 01:00:12 +0200
commit4b8a9a5189a625bf99fedec7fd31f6e146410a14 (patch)
treea29759d5f0f0c29f07c89c59f6b5cf38407d1470 /lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php
parentab82beef33f4c196383a81213dcdff4ebe9447ae (diff)
Update FB API library
Diffstat (limited to 'lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php')
-rwxr-xr-xlib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php57
1 files changed, 54 insertions, 3 deletions
diff --git a/lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php b/lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php
index cef0586..a77e754 100755
--- a/lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php
+++ b/lib/facebook-graph-sdk/tests/FacebookBatchRequestTest.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
@@ -36,7 +36,7 @@ class FacebookBatchRequestTest extends \PHPUnit_Framework_TestCase
*/
private $app;
- public function setUp()
+ protected function setUp()
{
$this->app = new FacebookApp('123', 'foo_secret');
}
@@ -280,6 +280,31 @@ class FacebookBatchRequestTest extends \PHPUnit_Framework_TestCase
], $batchRequestArray);
}
+ public function testBatchRequestsWithOptionsGetConvertedToAnArray()
+ {
+ $request = new FacebookRequest(null, null, 'GET', '/bar');
+ $batchRequest = $this->createBatchRequest();
+ $batchRequest->add($request, [
+ 'name' => 'foo_name',
+ 'omit_response_on_success' => false,
+ ]);
+
+ $requests = $batchRequest->getRequests();
+
+ $options = $requests[0]['options'];
+ $options['name'] = $requests[0]['name'];
+
+ $batchRequestArray = $batchRequest->requestEntityToBatchArray($requests[0]['request'], $options);
+
+ $this->assertEquals([
+ 'headers' => $this->defaultHeaders(),
+ 'method' => 'GET',
+ 'relative_url' => '/' . Facebook::DEFAULT_GRAPH_VERSION . '/bar?access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9',
+ 'name' => 'foo_name',
+ 'omit_response_on_success' => false,
+ ], $batchRequestArray);
+ }
+
public function testPreppingABatchRequestProperlySetsThePostParams()
{
$batchRequest = $this->createBatchRequest();
@@ -328,6 +353,30 @@ class FacebookBatchRequestTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedBatchParams, $params);
}
+ public function testPreppingABatchRequestWithOptionsProperlySetsThePostParams()
+ {
+ $batchRequest = $this->createBatchRequest();
+ $batchRequest->add(new FacebookRequest(null, null, 'GET', '/foo'), [
+ 'name' => 'foo_name',
+ 'omit_response_on_success' => false,
+ ]);
+
+ $batchRequest->prepareRequestsForBatch();
+ $params = $batchRequest->getParams();
+
+ $expectedHeaders = json_encode($this->defaultHeaders());
+ $version = Facebook::DEFAULT_GRAPH_VERSION;
+
+ $expectedBatchParams = [
+ 'batch' => '[{"headers":' . $expectedHeaders . ',"method":"GET","relative_url":"\\/' . $version . '\\/foo?access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9",'
+ . '"name":"foo_name","omit_response_on_success":false}]',
+ 'include_headers' => true,
+ 'access_token' => 'foo_token',
+ 'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9',
+ ];
+ $this->assertEquals($expectedBatchParams, $params);
+ }
+
private function assertRequestContainsAppAndToken(FacebookRequest $request, FacebookApp $expectedApp, $expectedToken)
{
$app = $request->getApp();
@@ -373,7 +422,9 @@ class FacebookBatchRequestTest extends \PHPUnit_Framework_TestCase
foreach ($requests as $name => $request) {
$expectedRequests[] = [
'name' => $name,
- 'request' => $request
+ 'request' => $request,
+ 'attached_files' => null,
+ 'options' => [],
];
}
$this->assertEquals($expectedRequests, $formattedRequests);