Reputation: 452
I'm developing an application that the only way to access the protected pages is through the Facebook's authentication. In this cenario, I need to login with a Facebook's test user and made my tests.
I'm using the PHP-SDK, so I need to figure out a way to login with an user test only with PHP (without javascript) and without a browser and cookies (because my tests runs only on command line, emulating a browser, without selenium for example).
Ideas about how I can test my protected pages that the only way to access is using a Facebook's user?
Upvotes: 2
Views: 545
Reputation: 530
Facebook now has test users, which can use most of Facebook except for interacting with real users. You can create them in your developer control panel or via the Graph API. There's even an API call that allows you to automatically create friendships between your test users. https://developers.facebook.com/docs/test_users/
Upvotes: 1
Reputation: 4775
I am not familiar with the PHP-SDK but on a more general level I would stub out Facebook.
Your tests don't need to depend on a third party service: the build might fail because Facebook is down and running your test will be slow as it needs to wait for Facebook to report back each time.
Can't you stub the Facebook endpoint and send your own response back (one that looks like the Facebook one)? You could do this with an HTTP faker. For Ruby I would use something like FakeWeb but there are probably some similar tools out there for PHP.
Upvotes: 1