2
include(dirname(__FILE__).'/../../bootstrap/functional.php');
5
* @see apps/frontend/lib/packages/agWebservicesPackage/config/routing.yml
6
* @see apps/frontend/lib/packages/agWebservicesPackage/data/fixtures.yml
9
$browser = new sfTestFunctional(new sfBrowser());
12
info(sprintf('Testing routes - without authentication'))->
13
get('/webservices/')->
14
with('request')->begin()->
15
isParameter('module', 'agWebservices')->
16
isParameter('action', 'index')->
18
with('response')->begin()->
20
checkElement('#web_service', 'Web Services')->
21
checkElement('#staff_link', 'Staff')->
22
checkElement('#organizations_link', 'Organizations')->
24
get('/webservices/index')->
25
with('request')->begin()->
26
isParameter('module', 'agWebservices')->
27
isParameter('action', 'index')->
29
with('response')->begin()->
31
checkElement('#web_service', 'Web Services')->
32
checkElement('#staff_link', 'Staff')->
33
checkElement('#organizations_link', 'Organizations')->
36
get('/webservices/list/staff')->
37
with('request')->begin()->
38
isParameter('module', 'agWebservices')->
39
isParameter('action', 'list')->
40
isParameter('datapoint', 'staff')->
42
with('response')->begin()->
44
checkElement('#columns h2', 'Staff Listing')->
45
checkElement('thead tr th', 'Id')->
48
get('/webservices/list/organizations')->
49
with('request')->begin()->
50
isParameter('module', 'agWebservices')->
51
isParameter('action', 'list')->
52
isParameter('datapoint', 'organizations')->
54
with('response')->begin()->
56
checkElement('#columns h2', 'Organizations Listing')->
57
checkElement('thead tr th', 'Id')->
60
info(sprintf('Accessing route /webservices/list with a wrong datapoint'))->
61
get('/webservices/list/person')->
62
with('response')->begin()->
66
info(sprintf('Staff in XML - valid token'))->
67
get('/webservices/staff.xml/agasti')->
68
with('request')->begin()->
69
isParameter('module', 'agWebservices')->
70
isParameter('action', 'get')->
71
isParameter('token', 'agasti')->
72
isParameter('datapoint', 'staff')->
73
isParameter('sf_format', 'xml')->
76
with('response')->begin()->
79
isHeader('Content-type', 'text/xml; charset=utf-8')->
80
checkElement('entity[type="staff"]', true)->
83
info(sprintf('Organizations in XML - valid token'))->
84
get('/webservices/organizations.xml/agasti')->
85
with('request')->begin()->
86
isParameter('module', 'agWebservices')->
87
isParameter('action', 'get')->
88
isParameter('token', 'agasti')->
89
isParameter('datapoint', 'organizations')->
90
isParameter('sf_format', 'xml')->
93
with('response')->begin()->
96
isHeader('Content-type', 'text/xml; charset=utf-8')->
97
checkElement('entity[type="organizations"]', true)->
100
info(sprintf('Staff in JSON - valid token'))->
101
get('/webservices/staff.json/agasti')->
102
with('request')->begin()->
103
isParameter('module', 'agWebservices')->
104
isParameter('action', 'get')->
105
isParameter('token', 'agasti')->
106
isParameter('datapoint', 'staff')->
107
isParameter('sf_format', 'json')->
110
with('response')->begin()->
112
isHeader('Content-type', 'application/json')->
113
matches('/"type"\:"staff"/')->
114
matches('/"id"\:"\d+"/')->
115
matches('/"person_id"\:"\d+"/')->
118
info(sprintf('Organizations in JSON - valid token'))->
119
get('/webservices/organizations.json/agasti')->
120
with('request')->begin()->
121
isParameter('module', 'agWebservices')->
122
isParameter('action', 'get')->
123
isParameter('token', 'agasti')->
124
isParameter('datapoint', 'organizations')->
125
isParameter('sf_format', 'json')->
128
with('response')->begin()->
130
isHeader('Content-type', 'application/json')->
131
matches('/"type"\:"organizations"/')->
132
matches('/"id"\:"\d+"/')->
133
matches('/"entity_id"\:"\d+"/')->
136
info(sprintf('Try to reach datapoint with invalid token'))->
137
get('/webservices/organizations.json/invalid_token')->
138
with('request')->begin()->
139
isParameter('module', 'agWebservices')->
140
isParameter('action', 'get')->
141
isParameter('token', 'invalid_token')->
142
isParameter('datapoint', 'organizations')->
143
isParameter('sf_format', 'json')->
146
with('response')->begin()->
150
info(sprintf('Try to reach datapoint with inactive client'))->
151
get('/webservices/organizations.json/inactive_client')->
152
with('request')->begin()->
153
isParameter('module', 'agWebservices')->
154
isParameter('action', 'get')->
155
isParameter('token', 'inactive_client')->
156
isParameter('datapoint', 'organizations')->
157
isParameter('sf_format', 'json')->
160
with('response')->begin()->
164
info(sprintf('Filter data through query params'))->
165
get('/webservices/staff.json/agasti/is_available=1&limit=10&person=1&order=staff')->
166
with('request')->begin()->
167
isParameter('module', 'agWebservices')->
168
isParameter('action', 'get')->
169
isParameter('token', 'agasti')->
170
isParameter('datapoint', 'staff')->
171
isParameter('sf_format', 'json')->
172
isParameter('url_param', 'is_available=1&limit=10&person=1&order=staff')->
175
with('response')->begin()->
177
matches('/"type"\:"staff"/')->
178
matches('/"id"\:"\d+"/')->
179
matches('/"person_id"\:"1"/')->
180
matches('/"is_available"\:true/')->
183
info(sprintf('Filter data through query params - no results'))->
184
get('/webservices/staff.xml/agasti/limit=0&is_available=0&person=1&order=staff')->
185
with('request')->begin()->
186
isParameter('module', 'agWebservices')->
187
isParameter('action', 'get')->
188
isParameter('token', 'agasti')->
189
isParameter('datapoint', 'staff')->
190
isParameter('sf_format', 'xml')->
191
isParameter('url_param', 'limit=0&is_available=0&person=1&order=staff')->
194
with('response')->begin()->
197
isHeader('Content-type', 'text/xml; charset=utf-8')->
198
checkElement('results', true)->
b'\\ No newline at end of file'