Skip to content

Commit 3e1a5d8

Browse files
committed
test & fix lowercase method name triggers destroy session
1 parent 2c81799 commit 3e1a5d8

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/base_facebook.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,9 @@ protected function _restserver($params) {
754754
$this->throwAPIException($result);
755755
}
756756

757-
if ($params['method'] === 'auth.expireSession' ||
758-
$params['method'] === 'auth.revokeAuthorization') {
757+
$method = strtolower($params['method']);
758+
if ($method === 'auth.expiresession' ||
759+
$method === 'auth.revokeauthorization') {
759760
$this->destroySession();
760761
}
761762

tests/tests.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,32 @@ public function testAuthExpireSessionDestroysSession() {
13061306
);
13071307
}
13081308

1309+
public function testLowercaseAuthRevokeAuthDestroysSession() {
1310+
$methods_to_stub = array(
1311+
'_oauthRequest',
1312+
'destroySession',
1313+
);
1314+
$constructor_args = array(array(
1315+
'appId' => self::APP_ID,
1316+
'secret' => self::SECRET
1317+
));
1318+
$key = 'foo';
1319+
$val = 42;
1320+
$stub = $this->getMock(
1321+
'TransientFacebook', $methods_to_stub, $constructor_args);
1322+
$stub
1323+
->expects($this->once())
1324+
->method('_oauthRequest')
1325+
->will($this->returnValue("{\"$key\":$val}"));
1326+
$stub
1327+
->expects($this->once())
1328+
->method('destroySession');
1329+
$this->assertEquals(
1330+
array($key => $val),
1331+
$stub->api(array('method' => 'auth.revokeauthorization'))
1332+
);
1333+
}
1334+
13091335
protected function generateMD5HashOfRandomValue() {
13101336
return md5(uniqid(mt_rand(), true));
13111337
}

0 commit comments

Comments
 (0)