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