Automated testing for Facebook SDK wrapper

Posted by Andree on Stack Overflow See other posts from Stack Overflow or by Andree
Published on 2010-05-30T19:32:16Z Indexed on 2010/05/30 19:42 UTC
Read the original article Hit count: 308

Filed under:
|

Hi there!

In my Facebook application, I have one Facebook wrapper class to encapsulates some call to Facebook API. I want to to write a unit test for this wrapper class, but since it depends on a so called "access token", which we should get from Facebook dynamically, I'm not sure if it's possible to write one.

But apparently the Facebook SDK itself has a PHPUnit test class. After studying the test code for a while, I know that involves a creation of dummy cookie-based session key.

private static $VALID_EXPIRED_SESSION = array(
    'access_token' => '254752073152|2.I_eTFkcTKSzX5no3jI4r1Q__.3600.1273359600-1677846385|uI7GwrmBUed8seZZ05JbdzGFUpk.',
    'expires' => '1273359600',
    'secret' => '0d9F7pxWjM_QakY_51VZqw__',
    'session_key' => '2.I_eTFkcTKSzX5no3jI4r1Q__.3600.1273359600-1677846385',
    'sig' => '9f6ae89510b30dddb3f864f3caf32fb3',
    'uid' => '1677846385'
);

.
.
.

$cookieName = 'fbs_' . self::APP_ID;
$session = self::$VALID_EXPIRED_SESSION;
$_COOKIE[$cookieName] = '"' . http_build_query($session) . '"';

What I don't understand is, how do I get the "access_token", "sig", "session_key" etc? As far as I'm concerned, it should be dynamically exchanged from Facebook and involves user action (logging in).

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about facebook