Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Campaign_SurveyUsageScenarioTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testSurveyUsageScenario() { | |
42daf119 | 39 | $this->webtestLogin('admin'); |
6a488035 TO |
40 | |
41 | // Create new group | |
42 | $title = substr(sha1(rand()), 0, 7); | |
43 | $groupName = $this->WebtestAddGroup(); | |
44 | ||
45 | // Adding contact | |
46 | $firstName1 = substr(sha1(rand()), 0, 7); | |
47 | $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); | |
48 | ||
49 | // add contact to group | |
50 | // visit group tab | |
51 | $this->click("css=li#tab_group a"); | |
0caa4679 | 52 | $this->waitForElementPresent("css=#group_id option"); |
6a488035 TO |
53 | |
54 | // add to group | |
55 | $this->select("group_id", "label=$groupName"); | |
56 | $this->click("_qf_GroupContact_next"); | |
642aa483 | 57 | $this->waitForElementPresent('link=Remove'); |
6a488035 TO |
58 | |
59 | $firstName2 = substr(sha1(rand()), 0, 7); | |
60 | $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); | |
61 | ||
62 | // add contact to group | |
63 | // visit group tab | |
64 | $this->click("css=li#tab_group a"); | |
0caa4679 | 65 | $this->waitForElementPresent("css=#group_id option"); |
6a488035 TO |
66 | |
67 | // add to group | |
68 | $this->select("group_id", "label=$groupName"); | |
69 | $this->click("_qf_GroupContact_next"); | |
642aa483 | 70 | $this->waitForElementPresent('link=Remove'); |
6a488035 | 71 | |
0bd37c06 | 72 | // Enable CiviCampaign module if necessary |
649c6141 | 73 | $this->enableComponents(array('CiviCampaign')); |
6a488035 | 74 | |
42daf119 | 75 | // add the required permission |
0bd37c06 | 76 | $this->changePermissions(array('edit-2-administer-civicampaign')); |
6a488035 | 77 | |
42daf119 CW |
78 | // Log in as normal user |
79 | $this->webtestLogin(); | |
80 | ||
6a488035 TO |
81 | $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); |
82 | ||
6a488035 TO |
83 | $this->type("title", "Campaign $title"); |
84 | ||
85 | // select the campaign type | |
86 | $this->select("campaign_type_id", "value=2"); | |
87 | ||
88 | // fill in the description | |
89 | $this->type("description", "This is a test campaign"); | |
90 | ||
91 | // include groups for the campaign | |
92 | $this->addSelection("includeGroups-f", "label=$groupName"); | |
93 | $this->click("//option[@value=4]"); | |
94 | $this->click("add"); | |
95 | ||
96 | // fill the end date for campaign | |
97 | $this->webtestFillDate("end_date", "+1 year"); | |
98 | ||
99 | // select campaign status | |
100 | $this->select("status_id", "value=2"); | |
101 | ||
102 | // click save | |
103 | $this->click("_qf_Campaign_upload-bottom"); | |
104 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
105 | ||
6c5f7368 | 106 | $this->waitForText('crm-notification-container', "$title"); |
6a488035 TO |
107 | |
108 | // create a custom data set for activities -> survey | |
109 | $this->openCiviPage('admin/custom/group', "action=add&reset=1", "_qf_Group_next-bottom"); | |
110 | // fill in a unique title for the custom group | |
111 | $this->type("title", "Group $title"); | |
112 | ||
113 | // select the group this custom data set extends | |
114 | $this->select("extends[0]", "value=Activity"); | |
115 | $this->waitForElementPresent("//select[@id='extends_1']"); | |
116 | $this->select("//select[@id='extends_1']", "label=Survey"); | |
117 | ||
118 | // save the custom group | |
119 | $this->click("_qf_Group_next-bottom"); | |
0bd37c06 | 120 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
121 | |
122 | // add a custom field to the custom group | |
123 | $this->type("label", "Field $title"); | |
124 | ||
125 | $this->select("data_type[1]", "value=Radio"); | |
126 | ||
127 | $this->waitForElementPresent("option_label_1"); | |
128 | ||
129 | // create a set of options | |
130 | $this->type("option_label_1", "Option $title 1"); | |
131 | $this->type("option_value_1", "1"); | |
132 | ||
133 | $this->type("option_label_2", "Option $title 2"); | |
134 | $this->type("option_value_2", "2"); | |
135 | ||
136 | // save the custom field | |
137 | $this->click("_qf_Field_next-bottom"); | |
138 | ||
139 | $this->waitForElementPresent("newCustomField"); | |
6c5f7368 | 140 | $this->waitForText('crm-notification-container', "$title"); |
6a488035 TO |
141 | |
142 | // create a profile for campaign | |
143 | $this->openCiviPage("admin/uf/group/add", "action=add&reset=1", "_qf_Group_next-bottom"); | |
144 | ||
145 | // fill in a unique title for the profile | |
146 | $this->type("title", "Profile $title"); | |
147 | ||
148 | // save the profile | |
149 | $this->click("_qf_Group_next-bottom"); | |
150 | ||
151 | $this->waitForElementPresent("_qf_Field_next-bottom"); | |
6c5f7368 | 152 | $this->waitForText('crm-notification-container', "$title"); |
6a488035 TO |
153 | |
154 | // add a profile field for activity | |
155 | $this->select("field_name[0]", "value=Activity"); | |
156 | $this->waitForElementPresent("field_name[1]"); | |
157 | $this->select("field_name[1]", "label=Field $title :: Group $title"); | |
158 | ||
159 | $this->click("_qf_Field_next-bottom"); | |
160 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 161 | $this->waitForText('crm-notification-container', "$title"); |
6a488035 TO |
162 | |
163 | // create a survey | |
164 | $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom"); | |
165 | ||
166 | // fill in a unique title for the survey | |
167 | $this->type("title", "Survey $title"); | |
168 | ||
169 | // select the created campaign | |
170 | $this->select("campaign_id", "label=Campaign $title"); | |
171 | ||
172 | // select the activity type | |
173 | $this->select("activity_type_id", "label=Survey"); | |
174 | ||
175 | // fill in reserve survey respondents | |
176 | $this->type("default_number_of_contacts", 50); | |
177 | ||
178 | // fill in interview survey respondents | |
179 | $this->type("max_number_of_contacts", 100); | |
180 | ||
181 | // release frequency | |
182 | $this->type("release_frequency", 2); | |
183 | ||
184 | $this->click("_qf_Main_upload-bottom"); | |
185 | $this->waitForElementPresent("_qf_Questions_upload_next-bottom"); | |
76e86fd8 | 186 | |
0bd37c06 | 187 | // Select the profile for the survey |
6a488035 TO |
188 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual"); |
189 | ||
76e86fd8 CW |
190 | // select the question created for the survey |
191 | ||
6a488035 TO |
192 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=Profile $title"); |
193 | $this->click("_qf_Questions_upload_next-bottom"); | |
194 | ||
195 | // create a set of options for Survey Responses _qf_Results_upload_done-bottom | |
196 | $this->waitForElementPresent('_qf_Results_upload_done-bottom'); | |
197 | $this->type("//input[@id='option_label_1']", "Label $title 1"); | |
198 | $this->type("//input[@id='option_value_1']", "1"); | |
199 | ||
200 | $this->type("//input[@id='option_label_2']", "Label $title 2"); | |
201 | $this->type("//input[@id='option_value_2']", "2"); | |
202 | $this->click('_qf_Results_upload_done-bottom'); | |
203 | $this->waitForElementPresent("//div[@id='search_form_survey']"); | |
6c5f7368 | 204 | $this->waitForText('crm-notification-container', "Results"); |
6a488035 TO |
205 | |
206 | // Reserve Respondents | |
207 | $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh"); | |
208 | ||
209 | // search for the respondents | |
210 | $this->select("campaign_survey_id", "label=Survey $title"); | |
211 | ||
212 | $this->click("_qf_Search_refresh"); | |
213 | ||
214 | $this->waitForElementPresent("Go"); | |
215 | $this->click("CIVICRM_QFID_ts_all_4"); | |
642aa483 | 216 | $this->select('task', "Reserve Respondents"); |
6a488035 TO |
217 | $this->click("Go"); |
218 | ||
219 | $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom"); | |
220 | $this->click("_qf_Reserve_done_reserve-bottom"); | |
221 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6e64f99d | 222 | $this->waitForText('crm-notification-container', "2 Contact\(s\) have been reserved"); |
6a488035 TO |
223 | |
224 | // Interview Respondents | |
225 | $this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh"); | |
226 | ||
227 | // search for the respondents | |
228 | $this->select("campaign_survey_id", "label=Survey $title"); | |
229 | ||
230 | $this->click("_qf_Search_refresh"); | |
231 | ||
232 | $this->waitForElementPresent("Go"); | |
233 | $this->click("CIVICRM_QFID_ts_all_4"); | |
234 | $this->click("Go"); | |
235 | ||
236 | $this->waitForElementPresent("_qf_Interview_cancel_interview"); | |
237 | ||
238 | $this->click("CIVICRM_QFID_1_2"); | |
239 | $this->select("css=#voterRecords .odd .result select", "value=Label $title 1"); | |
240 | $this->click("css=#voterRecords .odd td a"); | |
241 | ||
242 | $this->click("CIVICRM_QFID_2_8"); | |
243 | $this->select("css=#voterRecords .even .result select", "value=Label $title 2"); | |
244 | $this->click("css=#voterRecords .even td a"); | |
245 | ||
246 | $this->click("_qf_Interview_cancel_interview"); | |
247 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
248 | ||
249 | // add a contact to the group to test release respondents | |
250 | $firstName3 = substr(sha1(rand()), 0, 7); | |
251 | $this->webtestAddContact($firstName3, "James", "$firstName3.james@example.org"); | |
a471a3b6 | 252 | $id = $this->urlArg('cid'); |
6a488035 TO |
253 | $sortName3 = "James, $firstName3"; |
254 | ||
255 | // add contact to group | |
256 | // visit group tab | |
257 | $this->click("css=li#tab_group a"); | |
0caa4679 | 258 | $this->waitForElementPresent("css=#group_id option"); |
6a488035 TO |
259 | |
260 | // add to group | |
261 | $this->select("group_id", "label=$groupName"); | |
262 | $this->click("_qf_GroupContact_next"); | |
642aa483 | 263 | $this->waitForElementPresent('link=Remove'); |
6a488035 TO |
264 | |
265 | // Reserve Respondents | |
266 | $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh"); | |
267 | ||
268 | // search for the respondents | |
269 | $this->select("campaign_survey_id", "label=Survey $title"); | |
270 | ||
271 | $this->click("_qf_Search_refresh"); | |
272 | ||
273 | $this->waitForElementPresent("Go"); | |
274 | $this->click("CIVICRM_QFID_ts_all_4"); | |
642aa483 | 275 | $this->select('task', "Reserve Respondents"); |
6a488035 TO |
276 | $this->click("Go"); |
277 | ||
278 | $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom"); | |
279 | $this->click("_qf_Reserve_done_reserve-bottom"); | |
280 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6e64f99d | 281 | $this->waitForText('crm-notification-container', "1 Contact\(s\) have been reserved"); |
6a488035 TO |
282 | |
283 | // Release Respondents | |
284 | $this->openCiviPage("survey/search", "reset=1&op=release", "_qf_Search_refresh"); | |
285 | ||
286 | // search for the respondents | |
287 | $this->select("campaign_survey_id", "label=Survey $title"); | |
288 | ||
289 | $this->click("_qf_Search_refresh"); | |
290 | ||
291 | $this->waitForElementPresent("Go"); | |
6e64f99d | 292 | $this->click("xpath=id('mark_x_$id')"); |
642aa483 AS |
293 | $this->click("CIVICRM_QFID_ts_sel_2"); |
294 | $this->select("task", "label=Release Respondents"); | |
295 | $this->clickLink("Go", "_qf_Release_done-bottom", FALSE); | |
296 | $this->clickLink("_qf_Release_done-bottom", 'access', FALSE); | |
6c5f7368 | 297 | $this->waitForText('crm-notification-container', "released"); |
6a488035 TO |
298 | |
299 | // check whether contact is available for reserving again | |
300 | $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh"); | |
301 | ||
302 | // search for the respondents | |
303 | $this->select("campaign_survey_id", "label=Survey $title"); | |
304 | ||
305 | $this->click("_qf_Search_refresh"); | |
306 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
307 | $this->assertTrue($this->isTextPresent("1 Result"), "Result didn't show up after saving!"); | |
308 | } | |
309 | ||
310 | function testSurveyReportTest() { | |
42daf119 CW |
311 | $this->webtestLogin('admin'); |
312 | ||
313 | // Enable CiviCampaign module if necessary | |
314 | $this->enableComponents(array('CiviCampaign')); | |
315 | ||
316 | // add the required permission | |
317 | $this->changePermissions('edit-2-administer-civicampaign'); | |
318 | ||
6a488035 TO |
319 | $this->webtestLogin(); |
320 | ||
321 | // Create new group | |
322 | $title = substr(sha1(rand()), 0, 7); | |
323 | $groupName = $this->WebtestAddGroup(); | |
324 | ||
325 | // Adding contact | |
6a488035 TO |
326 | $firstName1 = substr(sha1(rand()), 0, 7); |
327 | $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); | |
a471a3b6 | 328 | $id1 = $this->urlArg('cid'); |
6a488035 TO |
329 | |
330 | // add contact to group | |
331 | // visit group tab | |
332 | $this->click("css=li#tab_group a"); | |
0caa4679 | 333 | $this->waitForElementPresent('css=#group_id option'); |
6a488035 TO |
334 | |
335 | // add to group | |
336 | $this->select("group_id", "label=$groupName"); | |
337 | $this->click("_qf_GroupContact_next"); | |
642aa483 | 338 | $this->waitForElementPresent('link=Remove'); |
6a488035 TO |
339 | |
340 | $firstName2 = substr(sha1(rand()), 0, 7); | |
341 | $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); | |
a471a3b6 | 342 | $id2 = $this->urlArg('cid'); |
6a488035 TO |
343 | |
344 | // add contact to group | |
345 | // visit group tab | |
346 | $this->click("css=li#tab_group a"); | |
0caa4679 | 347 | $this->waitForElementPresent('css=#group_id option'); |
6a488035 TO |
348 | |
349 | // add to group | |
350 | $this->select("group_id", "label=$groupName"); | |
351 | $this->click("_qf_GroupContact_next"); | |
642aa483 | 352 | $this->waitForElementPresent('link=Remove'); |
6a488035 TO |
353 | |
354 | // Create custom group and add custom data fields | |
355 | $this->openCiviPage("admin/custom/group", "reset=1"); | |
356 | ||
357 | $this->click("link=Add Set of Custom Fields"); | |
358 | $this->waitForElementPresent('_qf_Group_cancel-bottom'); | |
359 | ||
360 | $customGroup = "Custom Group $title"; | |
361 | $this->type('title', "$customGroup"); | |
362 | $this->select('extends[0]', "value=Contact"); | |
363 | $this->click('_qf_Group_next-bottom'); | |
364 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); | |
6c5f7368 | 365 | $this->waitForText('crm-notification-container', $customGroup); |
6a488035 TO |
366 | |
367 | // Add custom fields | |
368 | $field1 = "Checkbox $title"; | |
369 | $this->type('label', $field1); | |
370 | $this->select('data_type[1]', "value=CheckBox"); | |
371 | $this->waitForElementPresent('option_label_2'); | |
372 | ||
373 | // add multiple choice options | |
374 | $label1 = "Check $title One"; | |
375 | $value1 = 1; | |
376 | $this->type('option_label_1', $label1); | |
377 | $this->type('option_value_1', $value1); | |
378 | ||
379 | $label2 = "Check $title Two"; | |
380 | $value2 = 2; | |
381 | $this->type('option_label_2', $label2); | |
382 | $this->type('option_value_2', $value2); | |
383 | ||
384 | $this->click("link=another choice"); | |
385 | ||
386 | $label3 = "Check $title Three"; | |
387 | $value3 = 3; | |
388 | $this->type('option_label_3', $label3); | |
389 | $this->type('option_value_3', $value3); | |
390 | ||
391 | $this->click('_qf_Field_next-bottom'); | |
392 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 393 | $this->waitForText('crm-notification-container', $field1); |
6a488035 TO |
394 | |
395 | // Create a profile for survey | |
396 | $this->openCiviPage("admin/uf/group", "reset=1"); | |
397 | ||
398 | $this->click("link=Add Profile"); | |
399 | $this->waitForElementPresent('_qf_Group_cancel-bottom'); | |
400 | ||
401 | $surveyProfile = "Survey Profile $title"; | |
402 | $this->type('title', $surveyProfile); | |
403 | $this->click('_qf_Group_next-bottom'); | |
404 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); | |
6c5f7368 | 405 | $this->waitForText('crm-notification-container', $surveyProfile); |
6a488035 TO |
406 | |
407 | // Add fields to the profile | |
408 | // Phone ( Primary ) | |
409 | $this->select('field_name[0]', "value=Contact"); | |
410 | $this->select('field_name[1]', "value=phone"); | |
411 | $this->click('field_name[1]'); | |
412 | $this->select('visibility', "value=Public Pages and Listings"); | |
413 | $this->check('is_searchable'); | |
414 | $this->check('in_selector'); | |
225a8648 | 415 | $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom'); |
76e86fd8 | 416 | |
6a488035 TO |
417 | // Custom Data Fields |
418 | $this->select('field_name[0]', "value=Contact"); | |
419 | $this->select('field_name[1]', "label=$field1 :: $customGroup"); | |
420 | $this->click('field_name[1]'); | |
421 | $this->select('visibility', "value=Public Pages and Listings"); | |
422 | $this->check('is_searchable'); | |
423 | $this->check('in_selector'); | |
424 | $this->click('_qf_Field_next-bottom'); | |
425 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
426 | ||
6a488035 TO |
427 | // Create a survey |
428 | $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom"); | |
429 | ||
430 | // fill in a unique title for the survey | |
431 | $surveyTitle = "Survey $title"; | |
432 | $this->type('title', $surveyTitle); | |
433 | ||
434 | // select the created campaign | |
435 | //$this->select("campaign_id", "label=Campaign $title"); | |
436 | ||
437 | // select the activity type | |
438 | $this->select("activity_type_id", "label=Survey"); | |
439 | ||
440 | // fill in reserve survey respondents | |
441 | $this->type("default_number_of_contacts", 50); | |
442 | ||
443 | // fill in interview survey respondents | |
444 | $this->type("max_number_of_contacts", 100); | |
445 | ||
446 | // release frequency | |
447 | $this->type("release_frequency", 2); | |
448 | ||
449 | $this->click("_qf_Main_upload-bottom"); | |
450 | $this->waitForElementPresent("_qf_Questions_upload_next-bottom"); | |
76e86fd8 | 451 | |
6a488035 TO |
452 | //Select the profile for the survey |
453 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual"); | |
454 | ||
76e86fd8 CW |
455 | // select the question created for the survey |
456 | ||
6a488035 TO |
457 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=$surveyProfile"); |
458 | $this->click("_qf_Questions_upload_next-bottom"); | |
459 | ||
460 | // create a set of options for Survey Responses _qf_Results_upload_done-bottom | |
461 | $this->waitForElementPresent('_qf_Results_upload_done-bottom'); | |
462 | $optionLabel1 = "Label $title 1"; | |
463 | $this->type("//input[@id='option_label_1']", "$optionLabel1"); | |
464 | $this->type("//input[@id='option_value_1']", "1"); | |
465 | ||
466 | $optionLabel2 = "Label $title 2"; | |
467 | $this->type("//input[@id='option_label_2']", "$optionLabel2"); | |
468 | $this->type("//input[@id='option_value_2']", "2"); | |
469 | $this->type("//input[@id='report_title']", "Survey $title"); | |
470 | $this->click('_qf_Results_upload_done-bottom'); | |
471 | $this->waitForElementPresent("//div[@id='search_form_survey']"); | |
472 | $this->assertTrue($this->isTextPresent("'Results' have been saved."), | |
473 | "Status message didn't show up after saving survey!" | |
474 | ); | |
475 | ||
476 | // Reserve Respondents | |
477 | $this->openCiviPage("survey/search", "reset=1&op=reserve", '_qf_Search_refresh'); | |
478 | ||
479 | // search for the respondents | |
480 | // select survey | |
481 | $this->select('campaign_survey_id', "label=$surveyTitle"); | |
482 | ||
483 | // need to wait for Groups field to reload dynamically | |
642aa483 | 484 | $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']"); |
6a488035 TO |
485 | |
486 | // select group | |
642aa483 AS |
487 | $this->click('group'); |
488 | $this->select('group', "label=$groupName"); | |
6a488035 TO |
489 | $this->click('_qf_Search_refresh'); |
490 | ||
642aa483 | 491 | $this->waitForElementPresent('Go'); |
6a488035 | 492 | $this->click("CIVICRM_QFID_ts_all_4"); |
642aa483 | 493 | $this->select('task', "Reserve Respondents"); |
6a488035 TO |
494 | $this->click("Go"); |
495 | $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom'); | |
496 | ||
225a8648 | 497 | $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access'); |
6e64f99d | 498 | $this->waitForText('crm-notification-container', "2 Contact\(s\) have been reserved"); |
6a488035 TO |
499 | |
500 | $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit'); | |
501 | ||
502 | // Select columns to be displayed | |
503 | $this->check('fields[survey_id]'); | |
504 | $this->check('fields[survey_response]'); | |
505 | $this->select('survey_id_value', "label=$surveyTitle"); | |
506 | $this->select('status_id_value', "label=Reserved"); | |
507 | $this->click('_qf_SurveyDetails_submit'); | |
508 | $this->waitForElementPresent('_qf_SurveyDetails_submit_print'); | |
509 | $this->assertTrue($this->isTextPresent("Is equal to Reserved")); | |
510 | ||
511 | // commenting out the print assertion as print dialog which appears breaks the webtest | |
76e86fd8 | 512 | // as it is OS-related and cannot be handled through webtest |
6a488035 TO |
513 | |
514 | // $this->click('_qf_SurveyDetails_submit_print'); | |
515 | // $this->waitForPageToLoad($this->getTimeoutMsec()); | |
516 | ||
517 | // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle")); | |
518 | // $this->assertTrue($this->isTextPresent("Q1 = $field1")); | |
519 | // $this->assertTrue($this->isTextPresent("$value1 | $value2 | $value3")); | |
520 | ||
521 | // Interview Respondents | |
522 | $this->openCiviPage("survey/search", "reset=1&op=interview", '_qf_Search_refresh'); | |
523 | ||
524 | // search for the respondents | |
525 | // select survey | |
526 | $this->select('campaign_survey_id', "label=$surveyTitle"); | |
527 | ||
528 | // need to wait for Groups field to reload dynamically | |
642aa483 | 529 | $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']"); |
6a488035 TO |
530 | |
531 | // select group | |
642aa483 AS |
532 | $this->click('group'); |
533 | $this->select('group', "label=$groupName"); | |
534 | //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li"); | |
6a488035 TO |
535 | $this->click('_qf_Search_refresh'); |
536 | ||
642aa483 AS |
537 | $this->waitForElementPresent('Go'); |
538 | //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]"); | |
6a488035 TO |
539 | $this->click("mark_x_{$id1}"); |
540 | $this->click("Go"); | |
541 | $this->waitForElementPresent('_qf_Interview_cancel_interview'); | |
542 | ||
543 | $this->type("field_{$id1}_phone-Primary-1", 9876543210); | |
baaf85ee RN |
544 | $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[7]/input[2]/../label[text()='$label1']"); |
545 | $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[7]/input[6]/../label[text()='$label2']"); | |
6a488035 TO |
546 | $this->select("field_{$id1}_result", $optionLabel1); |
547 | $this->click("interview_voter_button_{$id1}"); | |
efb29358 CW |
548 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
549 | // Sleep should never be used for wait for anything to load from the server | |
550 | // Justification for this instance: FIXME | |
6a488035 TO |
551 | sleep(3); |
552 | // Survey Report | |
553 | $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit'); | |
554 | ||
555 | // Select columns to be displayed | |
556 | $this->check('fields[survey_id]'); | |
557 | $this->check('fields[survey_response]'); | |
558 | $this->select('survey_id_value', "label=$surveyTitle"); | |
559 | $this->select('status_id_value', "label=Interviewed"); | |
560 | $this->click('_qf_SurveyDetails_submit'); | |
561 | $this->waitForElementPresent('_qf_SurveyDetails_submit_print'); | |
562 | $this->assertTrue($this->isTextPresent("Is equal to Interviewed")); | |
563 | ||
564 | // commenting out the print assertion as print dialog which appears breaks the webtest | |
76e86fd8 | 565 | // as it is OS-related and cannot be handled through webtest |
6a488035 TO |
566 | |
567 | // $this->click('_qf_SurveyDetails_submit_print'); | |
568 | // $this->waitForPageToLoad($this->getTimeoutMsec()); | |
569 | ||
570 | // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle")); | |
571 | // $this->assertTrue($this->isTextPresent("Q1 = $field1")); | |
572 | // $this->assertTrue($this->isTextPresent("$value1")); | |
573 | ||
574 | // use GOTV (campaign/gotv) to mark the respondents as voted | |
575 | $this->openCiviPage("campaign/gotv", "reset=1"); | |
576 | ||
577 | // search for the respondents | |
578 | // select survey | |
579 | $this->select('campaign_survey_id', "label=$surveyTitle"); | |
580 | // need to wait for Groups field to reload dynamically | |
642aa483 | 581 | $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']"); |
6a488035 TO |
582 | |
583 | // select group | |
642aa483 AS |
584 | $this->click('group'); |
585 | $this->select('group', "label=$groupName"); | |
586 | //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li"); | |
587 | //$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']"); | |
588 | $this->click("link=Search"); | |
0bd37c06 | 589 | |
6a488035 TO |
590 | $this->waitForElementPresent("xpath=//table[@id='gotvVoterRecords']/tbody/tr/td[7]"); |
591 | $this->check("xpath=//table[@id='gotvVoterRecords']/tbody/tr/td[7]/input"); | |
592 | ||
593 | // Check title of the activities created | |
594 | $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh'); | |
595 | $this->select('activity_survey_id', "label=$surveyTitle"); | |
596 | $this->click('_qf_Search_refresh'); | |
597 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
598 | ||
642aa483 | 599 | $this->verifyText("xpath=//table/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]", |
6a488035 TO |
600 | preg_quote("$surveyTitle - Respondent Interview") |
601 | ); | |
642aa483 | 602 | $this->verifyText("xpath=//table/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]", |
6a488035 TO |
603 | preg_quote("$surveyTitle - Respondent Reservation") |
604 | ); | |
605 | } | |
606 | } | |
607 |