1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2017 Facebook, Inc. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
namespace Facebook\Tests; |
25
|
|
|
|
26
|
|
|
use Facebook\FacebookApp; |
27
|
|
|
use Facebook\FacebookRequest; |
28
|
|
|
use Facebook\FacebookBatchRequest; |
29
|
|
|
use Facebook\FileUpload\FacebookFile; |
30
|
|
|
use PHPUnit\Framework\TestCase; |
31
|
|
|
|
32
|
|
|
class FacebookBatchRequestTest extends TestCase |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var FacebookApp |
36
|
|
|
*/ |
37
|
|
|
private $app; |
38
|
|
|
|
39
|
|
|
protected function setUp() |
40
|
|
|
{ |
41
|
|
|
$this->app = new FacebookApp('123', 'foo_secret'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testABatchRequestWillInstantiateWithTheProperProperties() |
45
|
|
|
{ |
46
|
|
|
$batchRequest = new FacebookBatchRequest($this->app, [], 'foo_token', 'v0.1337'); |
47
|
|
|
|
48
|
|
|
$this->assertSame($this->app, $batchRequest->getApp()); |
49
|
|
|
$this->assertEquals('foo_token', $batchRequest->getAccessToken()); |
50
|
|
|
$this->assertEquals('POST', $batchRequest->getMethod()); |
51
|
|
|
$this->assertEquals('', $batchRequest->getEndpoint()); |
52
|
|
|
$this->assertEquals('v0.1337', $batchRequest->getGraphVersion()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testEmptyRequestWillFallbackToBatchDefaults() |
56
|
|
|
{ |
57
|
|
|
$request = new FacebookRequest(); |
58
|
|
|
|
59
|
|
|
$this->createBatchRequest()->addFallbackDefaults($request); |
60
|
|
|
|
61
|
|
|
$this->assertRequestContainsAppAndToken($request, $this->app, 'foo_token'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testRequestWithTokenOnlyWillFallbackToBatchDefaults() |
65
|
|
|
{ |
66
|
|
|
$request = new FacebookRequest(null, 'bar_token'); |
67
|
|
|
|
68
|
|
|
$this->createBatchRequest()->addFallbackDefaults($request); |
69
|
|
|
|
70
|
|
|
$this->assertRequestContainsAppAndToken($request, $this->app, 'bar_token'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function testRequestWithAppOnlyWillFallbackToBatchDefaults() |
74
|
|
|
{ |
75
|
|
|
$customApp = new FacebookApp('1337', 'bar_secret'); |
76
|
|
|
$request = new FacebookRequest($customApp); |
77
|
|
|
|
78
|
|
|
$this->createBatchRequest()->addFallbackDefaults($request); |
79
|
|
|
|
80
|
|
|
$this->assertRequestContainsAppAndToken($request, $customApp, 'foo_token'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @expectedException \Facebook\Exception\FacebookSDKException |
85
|
|
|
*/ |
86
|
|
|
public function testWillThrowWhenNoThereIsNoAppFallback() |
87
|
|
|
{ |
88
|
|
|
$batchRequest = new FacebookBatchRequest(); |
89
|
|
|
|
90
|
|
|
$batchRequest->addFallbackDefaults(new FacebookRequest(null, 'foo_token')); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @expectedException \Facebook\Exception\FacebookSDKException |
95
|
|
|
*/ |
96
|
|
|
public function testWillThrowWhenNoThereIsNoAccessTokenFallback() |
97
|
|
|
{ |
98
|
|
|
$request = new FacebookBatchRequest(); |
99
|
|
|
|
100
|
|
|
$request->addFallbackDefaults(new FacebookRequest($this->app)); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @expectedException \InvalidArgumentException |
105
|
|
|
*/ |
106
|
|
|
public function testAnInvalidTypeGivenToAddWillThrow() |
107
|
|
|
{ |
108
|
|
|
$request = new FacebookBatchRequest(); |
109
|
|
|
|
110
|
|
|
$request->add('foo'); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function testAddingRequestsWillBeFormattedInAnArrayProperly() |
114
|
|
|
{ |
115
|
|
|
$requests = [ |
116
|
|
|
null => new FacebookRequest(null, null, 'GET', '/foo'), |
117
|
|
|
'my-second-request' => new FacebookRequest(null, null, 'POST', '/bar', ['foo' => 'bar']), |
118
|
|
|
'my-third-request' => new FacebookRequest(null, null, 'DELETE', '/baz') |
119
|
|
|
]; |
120
|
|
|
|
121
|
|
|
$batchRequest = $this->createBatchRequest(); |
122
|
|
|
$batchRequest->add($requests[null]); |
123
|
|
|
$batchRequest->add($requests['my-second-request'], 'my-second-request'); |
124
|
|
|
$batchRequest->add($requests['my-third-request'], 'my-third-request'); |
125
|
|
|
|
126
|
|
|
$formattedRequests = $batchRequest->getRequests(); |
127
|
|
|
|
128
|
|
|
$this->assertRequestsMatch($requests, $formattedRequests); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
View Code Duplication |
public function testANumericArrayOfRequestsCanBeAdded() |
|
|
|
|
132
|
|
|
{ |
133
|
|
|
$requests = [ |
134
|
|
|
new FacebookRequest(null, null, 'GET', '/foo'), |
135
|
|
|
new FacebookRequest(null, null, 'POST', '/bar', ['foo' => 'bar']), |
136
|
|
|
new FacebookRequest(null, null, 'DELETE', '/baz'), |
137
|
|
|
]; |
138
|
|
|
|
139
|
|
|
$formattedRequests = $this->createBatchRequestWithRequests($requests)->getRequests(); |
140
|
|
|
|
141
|
|
|
$this->assertRequestsMatch($requests, $formattedRequests); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
View Code Duplication |
public function testAnAssociativeArrayOfRequestsCanBeAdded() |
|
|
|
|
145
|
|
|
{ |
146
|
|
|
$requests = [ |
147
|
|
|
'req-one' => new FacebookRequest(null, null, 'GET', '/foo'), |
148
|
|
|
'req-two' => new FacebookRequest(null, null, 'POST', '/bar', ['foo' => 'bar']), |
149
|
|
|
'req-three' => new FacebookRequest(null, null, 'DELETE', '/baz'), |
150
|
|
|
]; |
151
|
|
|
|
152
|
|
|
$formattedRequests = $this->createBatchRequestWithRequests($requests)->getRequests(); |
153
|
|
|
|
154
|
|
|
$this->assertRequestsMatch($requests, $formattedRequests); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function testRequestsCanBeInjectedIntoConstructor() |
158
|
|
|
{ |
159
|
|
|
$requests = [ |
160
|
|
|
new FacebookRequest(null, null, 'GET', '/foo'), |
161
|
|
|
new FacebookRequest(null, null, 'POST', '/bar', ['foo' => 'bar']), |
162
|
|
|
new FacebookRequest(null, null, 'DELETE', '/baz'), |
163
|
|
|
]; |
164
|
|
|
|
165
|
|
|
$batchRequest = new FacebookBatchRequest($this->app, $requests, 'foo_token'); |
166
|
|
|
$formattedRequests = $batchRequest->getRequests(); |
167
|
|
|
|
168
|
|
|
$this->assertRequestsMatch($requests, $formattedRequests); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @expectedException \Facebook\Exception\FacebookSDKException |
173
|
|
|
*/ |
174
|
|
|
public function testAZeroRequestCountWithThrow() |
175
|
|
|
{ |
176
|
|
|
$batchRequest = new FacebookBatchRequest($this->app, [], 'foo_token'); |
177
|
|
|
|
178
|
|
|
$batchRequest->validateBatchRequestCount(); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @expectedException \Facebook\Exception\FacebookSDKException |
183
|
|
|
*/ |
184
|
|
|
public function testMoreThanFiftyRequestsWillThrow() |
185
|
|
|
{ |
186
|
|
|
$batchRequest = $this->createBatchRequest(); |
187
|
|
|
|
188
|
|
|
$this->createAndAppendRequestsTo($batchRequest, 51); |
189
|
|
|
|
190
|
|
|
$batchRequest->validateBatchRequestCount(); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function testLessOrEqualThanFiftyRequestsWillNotThrow() |
194
|
|
|
{ |
195
|
|
|
$batchRequest = $this->createBatchRequest(); |
196
|
|
|
|
197
|
|
|
$this->createAndAppendRequestsTo($batchRequest, 50); |
198
|
|
|
|
199
|
|
|
$batchRequest->validateBatchRequestCount(); |
200
|
|
|
|
201
|
|
|
$this->assertTrue(true); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @dataProvider requestsAndExpectedResponsesProvider |
206
|
|
|
*/ |
207
|
|
|
public function testBatchRequestEntitiesProperlyGetConvertedToAnArray($request, $expectedArray) |
208
|
|
|
{ |
209
|
|
|
$batchRequest = $this->createBatchRequest(); |
210
|
|
|
$batchRequest->add($request, 'foo_name'); |
211
|
|
|
|
212
|
|
|
$requests = $batchRequest->getRequests(); |
213
|
|
|
$batchRequestArray = $batchRequest->requestEntityToBatchArray($requests[0]['request'], $requests[0]['name']); |
214
|
|
|
|
215
|
|
|
$this->assertEquals($expectedArray, $batchRequestArray); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function requestsAndExpectedResponsesProvider() |
219
|
|
|
{ |
220
|
|
|
$headers = $this->defaultHeaders(); |
221
|
|
|
|
222
|
|
|
return [ |
223
|
|
|
[ |
224
|
|
|
new FacebookRequest(null, null, 'GET', '/foo', ['foo' => 'bar']), |
225
|
|
|
[ |
226
|
|
|
'headers' => $headers, |
227
|
|
|
'method' => 'GET', |
228
|
|
|
'relative_url' => '/foo?foo=bar&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
229
|
|
|
'name' => 'foo_name', |
230
|
|
|
], |
231
|
|
|
], |
232
|
|
|
[ |
233
|
|
|
new FacebookRequest(null, null, 'POST', '/bar', ['bar' => 'baz']), |
234
|
|
|
[ |
235
|
|
|
'headers' => $headers, |
236
|
|
|
'method' => 'POST', |
237
|
|
|
'relative_url' => '/bar', |
238
|
|
|
'body' => 'bar=baz&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
239
|
|
|
'name' => 'foo_name', |
240
|
|
|
], |
241
|
|
|
], |
242
|
|
|
[ |
243
|
|
|
new FacebookRequest(null, null, 'DELETE', '/bar'), |
244
|
|
|
[ |
245
|
|
|
'headers' => $headers, |
246
|
|
|
'method' => 'DELETE', |
247
|
|
|
'relative_url' => '/bar?access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
248
|
|
|
'name' => 'foo_name', |
249
|
|
|
], |
250
|
|
|
], |
251
|
|
|
]; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
public function testBatchRequestsWithFilesGetConvertedToAnArray() |
255
|
|
|
{ |
256
|
|
|
$request = new FacebookRequest(null, null, 'POST', '/bar', [ |
257
|
|
|
'message' => 'foobar', |
258
|
|
|
'source' => new FacebookFile(__DIR__ . '/foo.txt'), |
259
|
|
|
]); |
260
|
|
|
|
261
|
|
|
$batchRequest = $this->createBatchRequest(); |
262
|
|
|
$batchRequest->add($request, 'foo_name'); |
263
|
|
|
|
264
|
|
|
$requests = $batchRequest->getRequests(); |
265
|
|
|
|
266
|
|
|
$attachedFiles = $requests[0]['attached_files']; |
267
|
|
|
|
268
|
|
|
$batchRequestArray = $batchRequest->requestEntityToBatchArray( |
269
|
|
|
$requests[0]['request'], |
270
|
|
|
$requests[0]['name'], |
271
|
|
|
$attachedFiles |
272
|
|
|
); |
273
|
|
|
|
274
|
|
|
$this->assertEquals([ |
275
|
|
|
'headers' => $this->defaultHeaders(), |
276
|
|
|
'method' => 'POST', |
277
|
|
|
'relative_url' => '/bar', |
278
|
|
|
'body' => 'message=foobar&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
279
|
|
|
'name' => 'foo_name', |
280
|
|
|
'attached_files' => $attachedFiles, |
281
|
|
|
], $batchRequestArray); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
public function testBatchRequestsWithOptionsGetConvertedToAnArray() |
285
|
|
|
{ |
286
|
|
|
$request = new FacebookRequest(null, null, 'GET', '/bar'); |
287
|
|
|
$batchRequest = $this->createBatchRequest(); |
288
|
|
|
$batchRequest->add($request, [ |
289
|
|
|
'name' => 'foo_name', |
290
|
|
|
'omit_response_on_success' => false, |
291
|
|
|
]); |
292
|
|
|
|
293
|
|
|
$requests = $batchRequest->getRequests(); |
294
|
|
|
|
295
|
|
|
$options = $requests[0]['options']; |
296
|
|
|
$options['name'] = $requests[0]['name']; |
297
|
|
|
|
298
|
|
|
$batchRequestArray = $batchRequest->requestEntityToBatchArray($requests[0]['request'], $options); |
299
|
|
|
|
300
|
|
|
$this->assertEquals([ |
301
|
|
|
'headers' => $this->defaultHeaders(), |
302
|
|
|
'method' => 'GET', |
303
|
|
|
'relative_url' => '/' . Facebook::DEFAULT_GRAPH_VERSION . '/bar?access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
304
|
|
|
'name' => 'foo_name', |
305
|
|
|
'omit_response_on_success' => false, |
306
|
|
|
], $batchRequestArray); |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
public function testPreppingABatchRequestProperlySetsThePostParams() |
310
|
|
|
{ |
311
|
|
|
$batchRequest = $this->createBatchRequest(); |
312
|
|
|
$batchRequest->add(new FacebookRequest(null, 'bar_token', 'GET', '/foo'), 'foo_name'); |
313
|
|
|
$batchRequest->add(new FacebookRequest(null, null, 'POST', '/bar', ['foo' => 'bar'])); |
314
|
|
|
$batchRequest->prepareRequestsForBatch(); |
315
|
|
|
|
316
|
|
|
$params = $batchRequest->getParams(); |
317
|
|
|
|
318
|
|
|
$expectedHeaders = json_encode($this->defaultHeaders()); |
319
|
|
|
$expectedBatchParams = [ |
320
|
|
|
'batch' => '[{"headers":' . $expectedHeaders . ',"method":"GET","relative_url":"\\/foo?access_token=bar_token&appsecret_proof=2ceec40b7b9fd7d38fff1767b766bcc6b1f9feb378febac4612c156e6a8354bd","name":"foo_name"},' |
321
|
|
|
. '{"headers":' . $expectedHeaders . ',"method":"POST","relative_url":"\\/bar","body":"foo=bar&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9"}]', |
322
|
|
|
'include_headers' => true, |
323
|
|
|
'access_token' => 'foo_token', |
324
|
|
|
'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
325
|
|
|
]; |
326
|
|
|
$this->assertEquals($expectedBatchParams, $params); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
public function testPreppingABatchRequestProperlyMovesTheFiles() |
330
|
|
|
{ |
331
|
|
|
$batchRequest = $this->createBatchRequest(); |
332
|
|
|
$batchRequest->add(new FacebookRequest(null, 'bar_token', 'GET', '/foo'), 'foo_name'); |
333
|
|
|
$batchRequest->add(new FacebookRequest(null, null, 'POST', '/me/photos', [ |
334
|
|
|
'message' => 'foobar', |
335
|
|
|
'source' => new FacebookFile(__DIR__ . '/foo.txt'), |
336
|
|
|
])); |
337
|
|
|
$batchRequest->prepareRequestsForBatch(); |
338
|
|
|
|
339
|
|
|
$params = $batchRequest->getParams(); |
340
|
|
|
$files = $batchRequest->getFiles(); |
341
|
|
|
|
342
|
|
|
$attachedFiles = implode(',', array_keys($files)); |
343
|
|
|
|
344
|
|
|
$expectedHeaders = json_encode($this->defaultHeaders()); |
345
|
|
|
$expectedBatchParams = [ |
346
|
|
|
'batch' => '[{"headers":' . $expectedHeaders . ',"method":"GET","relative_url":"\\/foo?access_token=bar_token&appsecret_proof=2ceec40b7b9fd7d38fff1767b766bcc6b1f9feb378febac4612c156e6a8354bd","name":"foo_name"},' |
347
|
|
|
. '{"headers":' . $expectedHeaders . ',"method":"POST","relative_url":"\\/me\\/photos","body":"message=foobar&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9","attached_files":"' . $attachedFiles . '"}]', |
348
|
|
|
'include_headers' => true, |
349
|
|
|
'access_token' => 'foo_token', |
350
|
|
|
'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
351
|
|
|
]; |
352
|
|
|
$this->assertEquals($expectedBatchParams, $params); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
public function testPreppingABatchRequestWithOptionsProperlySetsThePostParams() |
356
|
|
|
{ |
357
|
|
|
$batchRequest = $this->createBatchRequest(); |
358
|
|
|
$batchRequest->add(new FacebookRequest(null, null, 'GET', '/foo'), [ |
359
|
|
|
'name' => 'foo_name', |
360
|
|
|
'omit_response_on_success' => false, |
361
|
|
|
]); |
362
|
|
|
|
363
|
|
|
$batchRequest->prepareRequestsForBatch(); |
364
|
|
|
$params = $batchRequest->getParams(); |
365
|
|
|
|
366
|
|
|
$expectedHeaders = json_encode($this->defaultHeaders()); |
367
|
|
|
$version = Facebook::DEFAULT_GRAPH_VERSION; |
368
|
|
|
|
369
|
|
|
$expectedBatchParams = [ |
370
|
|
|
'batch' => '[{"headers":' . $expectedHeaders . ',"method":"GET","relative_url":"\\/' . $version . '\\/foo?access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9",' |
371
|
|
|
. '"name":"foo_name","omit_response_on_success":false}]', |
372
|
|
|
'include_headers' => true, |
373
|
|
|
'access_token' => 'foo_token', |
374
|
|
|
'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', |
375
|
|
|
]; |
376
|
|
|
$this->assertEquals($expectedBatchParams, $params); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
private function assertRequestContainsAppAndToken(FacebookRequest $request, FacebookApp $expectedApp, $expectedToken) |
380
|
|
|
{ |
381
|
|
|
$app = $request->getApp(); |
382
|
|
|
$token = $request->getAccessToken(); |
383
|
|
|
|
384
|
|
|
$this->assertSame($expectedApp, $app); |
385
|
|
|
$this->assertEquals($expectedToken, $token); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
private function defaultHeaders() |
389
|
|
|
{ |
390
|
|
|
$headers = []; |
391
|
|
|
foreach (FacebookRequest::getDefaultHeaders() as $name => $value) { |
392
|
|
|
$headers[] = $name . ': ' . $value; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
return $headers; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
private function createAndAppendRequestsTo(FacebookBatchRequest $batchRequest, $number) |
399
|
|
|
{ |
400
|
|
|
for ($i = 0; $i < $number; $i++) { |
401
|
|
|
$batchRequest->add(new FacebookRequest()); |
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
private function createBatchRequest() |
406
|
|
|
{ |
407
|
|
|
return new FacebookBatchRequest($this->app, [], 'foo_token'); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
private function createBatchRequestWithRequests(array $requests) |
411
|
|
|
{ |
412
|
|
|
$batchRequest = $this->createBatchRequest(); |
413
|
|
|
$batchRequest->add($requests); |
414
|
|
|
|
415
|
|
|
return $batchRequest; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
private function assertRequestsMatch($requests, $formattedRequests) |
419
|
|
|
{ |
420
|
|
|
$expectedRequests = []; |
421
|
|
|
foreach ($requests as $name => $request) { |
422
|
|
|
$expectedRequests[] = [ |
423
|
|
|
'name' => $name, |
424
|
|
|
'request' => $request, |
425
|
|
|
'attached_files' => null, |
426
|
|
|
'options' => [], |
427
|
|
|
]; |
428
|
|
|
} |
429
|
|
|
$this->assertEquals($expectedRequests, $formattedRequests); |
430
|
|
|
} |
431
|
|
|
} |
432
|
|
|
|