@@ -10,6 +10,9 @@ class FacebookTest extends PHPUnit_Framework_TestCase
10
10
const APP_ID = '117743971608120 ' ;
11
11
const SECRET = '943716006e74d9b9283d4d5d8ab93204 ' ;
12
12
13
+ const MIGRATED_APP_ID = '148931871805121 ' ;
14
+ const MIGRATED_SECRET = 'bb9b2bb536647ed3b92c1c9a8969ef7c ' ;
15
+
13
16
private static $ VALID_EXPIRED_SESSION = array (
14
17
'access_token ' => '117743971608120|2.vdCKd4ZIEJlHwwtrkilgKQ__.86400.1281049200-1677846385|NF_2DDNxFBznj2CuwiwabHhTAHc. ' ,
15
18
'expires ' => '1281049200 ' ,
@@ -224,7 +227,6 @@ public function testInvalidSessionFromQueryString() {
224
227
225
228
$ params = array (
226
229
'fb_sig_in_iframe ' => 1 ,
227
- 'fb_sig_iframe_key ' => '6512bd43d9caa6e02c990b0a82652dca ' ,
228
230
'fb_sig_user ' => '1677846385 ' ,
229
231
'fb_sig_session_key ' =>
230
232
'2.NdKHtYIuB0EcNSHOvqAKHg__.86400.1258092000-1677846385 ' ,
@@ -319,11 +321,11 @@ public function testGraphAPIWithSession() {
319
321
} catch (FacebookApiException $ e ) {
320
322
// means the server got the access token
321
323
$ msg = 'OAuthException: Error processing access token. ' ;
322
- $ this ->assertEquals ((string ) $ e, $ msg ,
324
+ $ this ->assertEquals ($ msg , (string ) $ e ,
323
325
'Expect the invalid session message. ' );
324
326
// also ensure the session was reset since it was invalid
325
327
$ this ->assertEquals ($ facebook ->getSession (), null ,
326
- 'Expect the to be reset. ' );
328
+ 'Expect the session to be reset. ' );
327
329
}
328
330
}
329
331
@@ -339,7 +341,48 @@ public function testGraphAPIMethod() {
339
341
} catch (FacebookApiException $ e ) {
340
342
// ProfileDelete means the server understood the DELETE
341
343
$ msg = 'GraphMethodException: Unsupported delete request. ' ;
342
- $ this ->assertEquals ((string ) $ e , $ msg ,
344
+ $ this ->assertEquals ($ msg , (string ) $ e ,
345
+ 'Expect the invalid session message. ' );
346
+ }
347
+ }
348
+
349
+ public function testGraphAPIOAuthSpecError () {
350
+ $ facebook = new Facebook (array (
351
+ 'appId ' => self ::MIGRATED_APP_ID ,
352
+ 'secret ' => self ::MIGRATED_SECRET ,
353
+ ));
354
+
355
+ try {
356
+ $ response = $ facebook ->api ('/me ' , array (
357
+ 'client_id ' => self ::MIGRATED_APP_ID ));
358
+
359
+ $ this ->fail ('Should not get here. ' );
360
+ } catch (FacebookApiException $ e ) {
361
+ // means the server got the access token
362
+ $ msg = 'invalid_request: An active access token must be used ' .
363
+ 'to query information about the current user. ' ;
364
+ $ this ->assertEquals ($ msg , (string ) $ e ,
365
+ 'Expect the invalid session message. ' );
366
+ // also ensure the session was reset since it was invalid
367
+ $ this ->assertEquals ($ facebook ->getSession (), null ,
368
+ 'Expect the session to be reset. ' );
369
+ }
370
+ }
371
+
372
+ public function testGraphAPIMethodOAuthSpecError () {
373
+ $ facebook = new Facebook (array (
374
+ 'appId ' => self ::MIGRATED_APP_ID ,
375
+ 'secret ' => self ::MIGRATED_SECRET ,
376
+ ));
377
+
378
+ try {
379
+ $ response = $ facebook ->api ('/naitik ' , 'DELETE ' , array (
380
+ 'client_id ' => self ::MIGRATED_APP_ID ));
381
+ $ this ->fail ('Should not get here. ' );
382
+ } catch (FacebookApiException $ e ) {
383
+ // ProfileDelete means the server understood the DELETE
384
+ $ msg = 'invalid_request: Unsupported delete request. ' ;
385
+ $ this ->assertEquals ($ msg , (string ) $ e ,
343
386
'Expect the invalid session message. ' );
344
387
}
345
388
}
@@ -350,6 +393,11 @@ public function testCurlFailure() {
350
393
'secret ' => self ::SECRET ,
351
394
));
352
395
396
+ if (!defined ('CURLOPT_TIMEOUT_MS ' )) {
397
+ // can't test it if we don't have millisecond timeouts
398
+ return ;
399
+ }
400
+
353
401
try {
354
402
// we dont expect facebook will ever return in 1ms
355
403
Facebook::$ CURL_OPTS [CURLOPT_TIMEOUT_MS ] = 1 ;
@@ -371,7 +419,7 @@ public function testGraphAPIWithOnlyParams() {
371
419
'secret ' => self ::SECRET ,
372
420
));
373
421
374
- $ response = $ facebook ->api ('/platform /feed ' ,
422
+ $ response = $ facebook ->api ('/331218348435 /feed ' ,
375
423
array ('limit ' => 1 , 'access_token ' => '' ));
376
424
$ this ->assertEquals (1 , count ($ response ['data ' ]), 'should get one entry ' );
377
425
$ this ->assertTrue (
0 commit comments