commit | author | age
|
2207d6
|
1 |
# Facebook |
W |
2 |
|
|
3 |
|
|
4 |
Provides testing for projects integrated with Facebook API. |
|
5 |
Relies on Facebook's tool Test User API. |
|
6 |
|
|
7 |
<div class="alert alert-info"> |
|
8 |
To use this module with Composer you need <em>"facebook/php-sdk4": "5.*"</em> package. |
|
9 |
</div> |
|
10 |
|
|
11 |
## Status |
|
12 |
|
|
13 |
[ ![Facebook Status for Codeception/Codeception](https://codeship.com/projects/e4bc90d0-1ed5-0134-566c-1ed679ae6c9d/status?branch=2.2)](https://codeship.com/projects/160201) |
|
14 |
|
|
15 |
* Stability: **beta** |
|
16 |
* Maintainer: **tiger-seo** |
|
17 |
* Contact: tiger.seo@codeception.com |
|
18 |
|
|
19 |
## Config |
|
20 |
|
|
21 |
* app_id *required* - Facebook application ID |
|
22 |
* secret *required* - Facebook application secret |
|
23 |
* test_user - Facebook test user parameters: |
|
24 |
* name - You can specify a name for the test user you create. The specified name will also be used in the email address assigned to the test user. |
|
25 |
* locale - You can specify a locale for the test user you create, the default is en_US. The list of supported locales is available at https://www.facebook.com/translations/FacebookLocales.xml |
|
26 |
* permissions - An array of permissions. Your app is granted these permissions for the new test user. The full list of permissions is available at https://developers.facebook.com/docs/authentication/permissions |
|
27 |
|
|
28 |
### Config example |
|
29 |
|
|
30 |
modules: |
|
31 |
enabled: |
|
32 |
- Facebook: |
|
33 |
depends: PhpBrowser |
|
34 |
app_id: 412345678901234 |
|
35 |
secret: ccb79c1b0fdff54e4f7c928bf233aea5 |
|
36 |
test_user: |
|
37 |
name: FacebookGuy |
|
38 |
locale: uk_UA |
|
39 |
permissions: [email, publish_stream] |
|
40 |
|
|
41 |
### Test example: |
|
42 |
|
|
43 |
``` php |
|
44 |
<?php |
|
45 |
$I = new ApiGuy($scenario); |
|
46 |
$I->am('Guest'); |
|
47 |
$I->wantToTest('check-in to a place be published on the Facebook using API'); |
|
48 |
$I->haveFacebookTestUserAccount(); |
|
49 |
$accessToken = $I->grabFacebookTestUserAccessToken(); |
|
50 |
$I->haveHttpHeader('Auth', 'FacebookToken ' . $accessToken); |
|
51 |
$I->amGoingTo('send request to the backend, so that it will publish on user\'s wall on Facebook'); |
|
52 |
$I->sendPOST('/api/v1/some-api-endpoint'); |
|
53 |
$I->seePostOnFacebookWithAttachedPlace('167724369950862'); |
|
54 |
|
|
55 |
``` |
|
56 |
|
|
57 |
``` php |
|
58 |
<?php |
|
59 |
$I = new WebGuy($scenario); |
|
60 |
$I->am('Guest'); |
|
61 |
$I->wantToTest('log in to site using Facebook'); |
|
62 |
$I->haveFacebookTestUserAccount(); // create facebook test user |
|
63 |
$I->haveTestUserLoggedInOnFacebook(); // so that facebook will not ask us for login and password |
|
64 |
$fbUserFirstName = $I->grabFacebookTestUserFirstName(); |
|
65 |
$I->amOnPage('/welcome'); |
|
66 |
$I->see('Welcome, Guest'); |
|
67 |
$I->click('Login with Facebook'); |
|
68 |
$I->see('Welcome, ' . $fbUserFirstName); |
|
69 |
|
|
70 |
``` |
|
71 |
|
|
72 |
@since 1.6.3 |
|
73 |
@author tiger.seo@gmail.com |
|
74 |
|
|
75 |
## Actions |
|
76 |
|
|
77 |
### grabFacebookTestUserAccessToken |
|
78 |
|
|
79 |
Returns the test user access token. |
|
80 |
|
|
81 |
* `return` string |
|
82 |
|
|
83 |
|
|
84 |
### grabFacebookTestUserEmail |
|
85 |
|
|
86 |
Returns the test user email. |
|
87 |
|
|
88 |
* `return` string |
|
89 |
|
|
90 |
|
|
91 |
### grabFacebookTestUserId |
|
92 |
|
|
93 |
Returns the test user id. |
|
94 |
|
|
95 |
* `return` string |
|
96 |
|
|
97 |
|
|
98 |
### grabFacebookTestUserLoginUrl |
|
99 |
|
|
100 |
Returns URL for test user auto-login. |
|
101 |
|
|
102 |
* `return` string |
|
103 |
|
|
104 |
|
|
105 |
### grabFacebookTestUserName |
|
106 |
|
|
107 |
Returns the test user name. |
|
108 |
|
|
109 |
* `return` string |
|
110 |
|
|
111 |
|
|
112 |
### grabFacebookTestUserPassword |
|
113 |
__not documented__ |
|
114 |
|
|
115 |
|
|
116 |
### haveFacebookTestUserAccount |
|
117 |
|
|
118 |
Get facebook test user be created. |
|
119 |
|
|
120 |
*Please, note that the test user is created only at first invoke, unless $renew arguments is true.* |
|
121 |
|
|
122 |
* `param bool` $renew true if the test user should be recreated |
|
123 |
|
|
124 |
|
|
125 |
### haveTestUserLoggedInOnFacebook |
|
126 |
|
|
127 |
Get facebook test user be logged in on facebook. |
|
128 |
This is done by going to facebook.com |
|
129 |
|
|
130 |
@throws ModuleConfigException |
|
131 |
|
|
132 |
|
|
133 |
### postToFacebookAsTestUser |
|
134 |
|
|
135 |
Please, note that you must have publish_actions permission to be able to publish to user's feed. |
|
136 |
|
|
137 |
* `param array` $params |
|
138 |
|
|
139 |
|
|
140 |
### seePostOnFacebookWithAttachedPlace |
|
141 |
|
|
142 |
Please, note that you must have publish_actions permission to be able to publish to user's feed. |
|
143 |
|
|
144 |
* `param string` $placeId Place identifier to be verified against user published posts |
|
145 |
|
|
146 |
|
|
147 |
### seePostOnFacebookWithMessage |
|
148 |
|
|
149 |
Please, note that you must have publish_actions permission to be able to publish to user's feed. |
|
150 |
|
|
151 |
* `param string` $message published post to be verified against the actual post on facebook |
|
152 |
|
|
153 |
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.5/src/Codeception/Module/Facebook.php">Help us to improve documentation. Edit module reference</a></div> |