Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
test destroy clears cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
daaku committed Jul 16, 2012
1 parent 420c008 commit 920cdbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/base_facebook.php
Expand Up @@ -1203,11 +1203,13 @@ public function destroySession() {

setcookie($cookie_name, '', 0, '/', $base_domain);
} else {
// @codeCoverageIgnoreStart
self::errorLog(
'There exists a cookie that we wanted to clear that we couldn\'t '.
'clear because headers was already sent. Make sure to do the first '.
'API call before outputing anything'
);
// @codeCoverageIgnoreEnd
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/tests.php
Expand Up @@ -1255,6 +1255,18 @@ public function testExceptionToString() {
$this->assertEquals('Exception: 1: foo', (string) $e);
}

public function testDestroyClearsCookie() {
$fb = new FBGetSignedRequestCookieFacebook(array(
'appId' => self::APP_ID,
'secret' => self::SECRET,
));
$_COOKIE[$fb->publicGetSignedRequestCookieName()] = 'foo';
$_SERVER['HTTP_HOST'] = 'fbrell.com';
$fb->destroySession();
$this->assertFalse(
array_key_exists($fb->publicGetSignedRequestCookieName(), $_COOKIE));
}

protected function generateMD5HashOfRandomValue() {
return md5(uniqid(mt_rand(), true));
}
Expand Down

0 comments on commit 920cdbb

Please sign in to comment.