~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to test/functional/frontend/WebservicesActionsTest.php

  • Committer: Fabio Albuquerque
  • Date: 2011-08-20 19:17:20 UTC
  • Revision ID: fabiocbalbuquerque@gmail.com-20110820191720-tllqbrgm3zc3tp6w
Improvements in functional tests, 'where' clauses using filters

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
$browser->
12
12
  info(sprintf('Testing routes - without authentication'))->
13
 
  get('/webservices')->
 
13
  get('/webservices/')->
14
14
  with('request')->begin()->
15
15
    isParameter('module', 'agWebservices')->
16
16
    isParameter('action', 'index')->
64
64
    end()->
65
65
    
66
66
  info(sprintf('Staff in XML - valid token'))->
67
 
  get('/webservices/get/agasti/staff.xml')->
 
67
  get('/webservices/staff.xml/agasti')->
68
68
  with('request')->begin()->
69
69
    isParameter('module', 'agWebservices')->
70
70
    isParameter('action', 'get')->
81
81
    end()->
82
82
    
83
83
  info(sprintf('Organizations in XML - valid token'))->
84
 
  get('/webservices/get/agasti/organizations.xml')->
 
84
  get('/webservices/organizations.xml/agasti')->
85
85
  with('request')->begin()->
86
86
    isParameter('module', 'agWebservices')->
87
87
    isParameter('action', 'get')->
98
98
    end()->
99
99
    
100
100
  info(sprintf('Staff in JSON - valid token'))->
101
 
  get('/webservices/get/agasti/staff.json')->
 
101
  get('/webservices/staff.json/agasti')->
102
102
  with('request')->begin()->
103
103
    isParameter('module', 'agWebservices')->
104
104
    isParameter('action', 'get')->
112
112
    isHeader('Content-type', 'application/json')->
113
113
    matches('/"type"\:"staff"/')->
114
114
    matches('/"id"\:"\d+"/')->
 
115
    matches('/"person_id"\:"\d+"/')->
115
116
    end()->
116
117
    
117
118
  info(sprintf('Organizations in JSON - valid token'))->
118
 
  get('/webservices/get/agasti/organizations.json')->
 
119
  get('/webservices/organizations.json/agasti')->
119
120
  with('request')->begin()->
120
121
    isParameter('module', 'agWebservices')->
121
122
    isParameter('action', 'get')->
133
134
    end()->
134
135
    
135
136
  info(sprintf('Try to reach datapoint with invalid token'))->
136
 
  get('/webservices/get/invalid_token/organizations.json')->
 
137
  get('/webservices/organizations.json/invalid_token')->
137
138
  with('request')->begin()->
138
139
    isParameter('module', 'agWebservices')->
139
140
    isParameter('action', 'get')->
147
148
    end()->
148
149
    
149
150
  info(sprintf('Try to reach datapoint with inactive client'))->
150
 
  get('/webservices/get/inactive_client/organizations.json')->
 
151
  get('/webservices/organizations.json/inactive_client')->
151
152
  with('request')->begin()->
152
153
    isParameter('module', 'agWebservices')->
153
154
    isParameter('action', 'get')->
158
159
    end()->
159
160
  with('response')->begin()->
160
161
    isStatusCode(404)->
 
162
    end()->
 
163
 
 
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')->
 
173
    isFormat('json')->
 
174
    end()->
 
175
  with('response')->begin()->
 
176
    isStatusCode(200)->
 
177
    matches('/"type"\:"staff"/')->
 
178
    matches('/"id"\:"\d+"/')->
 
179
    matches('/"person_id"\:"1"/')->
 
180
    matches('/"is_available"\:true/')->
 
181
    end()->
 
182
 
 
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')->
 
192
    isFormat('xml')->
 
193
    end()->
 
194
  with('response')->begin()->
 
195
    isStatusCode(200)->
 
196
    isValid()->
 
197
    isHeader('Content-type', 'text/xml; charset=utf-8')->
 
198
    checkElement('results', true)->
161
199
    end()
162
200
;
 
 
b'\\ No newline at end of file'