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 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testSurveyUsageScenario() { | |
36 | $this->webtestLogin(); | |
37 | ||
38 | // Create new group | |
39 | $title = substr(sha1(rand()), 0, 7); | |
40 | $groupName = $this->WebtestAddGroup(); | |
41 | ||
42 | // Adding contact | |
43 | $firstName1 = substr(sha1(rand()), 0, 7); | |
44 | $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); | |
45 | ||
46 | // add contact to group | |
47 | // visit group tab | |
48 | $this->click("css=li#tab_group a"); | |
49 | $this->waitForElementPresent("group_id"); | |
50 | ||
51 | // add to group | |
52 | $this->select("group_id", "label=$groupName"); | |
53 | $this->click("_qf_GroupContact_next"); | |
54 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
55 | ||
56 | $firstName2 = substr(sha1(rand()), 0, 7); | |
57 | $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); | |
58 | ||
59 | // add contact to group | |
60 | // visit group tab | |
61 | $this->click("css=li#tab_group a"); | |
62 | $this->waitForElementPresent("group_id"); | |
63 | ||
64 | // add to group | |
65 | $this->select("group_id", "label=$groupName"); | |
66 | $this->click("_qf_GroupContact_next"); | |
67 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
68 | ||
0bd37c06 | 69 | // Enable CiviCampaign module if necessary |
649c6141 | 70 | $this->enableComponents(array('CiviCampaign')); |
6a488035 TO |
71 | |
72 | // add the required Drupal permission | |
0bd37c06 | 73 | $this->changePermissions(array('edit-2-administer-civicampaign')); |
6a488035 TO |
74 | |
75 | // Go directly to the URL of the screen that you will be testing | |
76 | $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); | |
77 | ||
78 | // Let's start filling the form with values. | |
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"); | |
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 | ||
186 | // select the question created for the survey | |
187 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=Profile $title"); | |
188 | $this->click("_qf_Questions_upload_next-bottom"); | |
189 | ||
190 | // create a set of options for Survey Responses _qf_Results_upload_done-bottom | |
191 | $this->waitForElementPresent('_qf_Results_upload_done-bottom'); | |
192 | $this->type("//input[@id='option_label_1']", "Label $title 1"); | |
193 | $this->type("//input[@id='option_value_1']", "1"); | |
194 | ||
195 | $this->type("//input[@id='option_label_2']", "Label $title 2"); | |
196 | $this->type("//input[@id='option_value_2']", "2"); | |
197 | $this->click('_qf_Results_upload_done-bottom'); | |
198 | $this->waitForElementPresent("//div[@id='search_form_survey']"); | |
199 | $this->assertElementContainsText("crm-notification-container", "Results"); | |
200 | ||
201 | // Reserve Respondents | |
202 | $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh"); | |
203 | ||
204 | // search for the respondents | |
205 | $this->select("campaign_survey_id", "label=Survey $title"); | |
206 | ||
207 | $this->click("_qf_Search_refresh"); | |
208 | ||
209 | $this->waitForElementPresent("Go"); | |
210 | $this->click("CIVICRM_QFID_ts_all_4"); | |
211 | $this->click("Go"); | |
212 | ||
213 | $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom"); | |
214 | $this->click("_qf_Reserve_done_reserve-bottom"); | |
215 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
216 | $this->assertElementContainsText("crm-notification-container", "2"); | |
217 | ||
218 | // Interview Respondents | |
219 | $this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh"); | |
220 | ||
221 | // search for the respondents | |
222 | $this->select("campaign_survey_id", "label=Survey $title"); | |
223 | ||
224 | $this->click("_qf_Search_refresh"); | |
225 | ||
226 | $this->waitForElementPresent("Go"); | |
227 | $this->click("CIVICRM_QFID_ts_all_4"); | |
228 | $this->click("Go"); | |
229 | ||
230 | $this->waitForElementPresent("_qf_Interview_cancel_interview"); | |
231 | ||
232 | $this->click("CIVICRM_QFID_1_2"); | |
233 | $this->select("css=#voterRecords .odd .result select", "value=Label $title 1"); | |
234 | $this->click("css=#voterRecords .odd td a"); | |
235 | ||
236 | $this->click("CIVICRM_QFID_2_8"); | |
237 | $this->select("css=#voterRecords .even .result select", "value=Label $title 2"); | |
238 | $this->click("css=#voterRecords .even td a"); | |
239 | ||
240 | $this->click("_qf_Interview_cancel_interview"); | |
241 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
242 | ||
243 | // add a contact to the group to test release respondents | |
244 | $firstName3 = substr(sha1(rand()), 0, 7); | |
245 | $this->webtestAddContact($firstName3, "James", "$firstName3.james@example.org"); | |
246 | $url = $this->getLocation(); | |
247 | $id = explode('cid=', $url); | |
248 | $sortName3 = "James, $firstName3"; | |
249 | ||
250 | // add contact to group | |
251 | // visit group tab | |
252 | $this->click("css=li#tab_group a"); | |
253 | $this->waitForElementPresent("group_id"); | |
254 | ||
255 | // add to group | |
256 | $this->select("group_id", "label=$groupName"); | |
257 | $this->click("_qf_GroupContact_next"); | |
258 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
259 | ||
260 | // Reserve Respondents | |
261 | $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh"); | |
262 | ||
263 | // search for the respondents | |
264 | $this->select("campaign_survey_id", "label=Survey $title"); | |
265 | ||
266 | $this->click("_qf_Search_refresh"); | |
267 | ||
268 | $this->waitForElementPresent("Go"); | |
269 | $this->click("CIVICRM_QFID_ts_all_4"); | |
270 | $this->click("Go"); | |
271 | ||
272 | $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom"); | |
273 | $this->click("_qf_Reserve_done_reserve-bottom"); | |
274 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
0bd37c06 | 275 | $this->assertElementContainsText("crm-notification-container", "Contact(s) have been reserved"); |
6a488035 TO |
276 | |
277 | // Release Respondents | |
278 | $this->openCiviPage("survey/search", "reset=1&op=release", "_qf_Search_refresh"); | |
279 | ||
280 | // search for the respondents | |
281 | $this->select("campaign_survey_id", "label=Survey $title"); | |
282 | ||
283 | $this->click("_qf_Search_refresh"); | |
284 | ||
285 | $this->waitForElementPresent("Go"); | |
286 | $this->click("xpath=id('mark_x_$id[1]')"); | |
287 | ||
288 | $this->waitForElementPresent("Go"); | |
289 | $this->click("Go"); | |
290 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
291 | ||
292 | $this->waitForElementPresent("_qf_Release_done-bottom"); | |
293 | $this->click("_qf_Release_done-bottom"); | |
294 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
295 | // wait for Access Keys div to appear at bottom of page - since this page may take a while | |
296 | $this->waitForElementPresent('access'); | |
297 | $this->assertElementContainsText("crm-notification-container", "released"); | |
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() { | |
311 | $this->webtestLogin(); | |
312 | ||
313 | // Create new group | |
314 | $title = substr(sha1(rand()), 0, 7); | |
315 | $groupName = $this->WebtestAddGroup(); | |
316 | ||
317 | // Adding contact | |
6a488035 TO |
318 | $firstName1 = substr(sha1(rand()), 0, 7); |
319 | $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); | |
320 | $url1 = explode('cid=', $this->getLocation()); | |
321 | $id1 = $url1[1]; | |
322 | ||
323 | // add contact to group | |
324 | // visit group tab | |
325 | $this->click("css=li#tab_group a"); | |
326 | $this->waitForElementPresent('group_id'); | |
327 | ||
328 | // add to group | |
329 | $this->select("group_id", "label=$groupName"); | |
330 | $this->click("_qf_GroupContact_next"); | |
331 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
332 | ||
333 | $firstName2 = substr(sha1(rand()), 0, 7); | |
334 | $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); | |
335 | $url2 = explode('cid=', $this->getLocation()); | |
336 | $id2 = $url2[1]; | |
337 | ||
338 | // add contact to group | |
339 | // visit group tab | |
340 | $this->click("css=li#tab_group a"); | |
341 | $this->waitForElementPresent('group_id'); | |
342 | ||
343 | // add to group | |
344 | $this->select("group_id", "label=$groupName"); | |
345 | $this->click("_qf_GroupContact_next"); | |
346 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
347 | ||
348 | // Create custom group and add custom data fields | |
349 | $this->openCiviPage("admin/custom/group", "reset=1"); | |
350 | ||
351 | $this->click("link=Add Set of Custom Fields"); | |
352 | $this->waitForElementPresent('_qf_Group_cancel-bottom'); | |
353 | ||
354 | $customGroup = "Custom Group $title"; | |
355 | $this->type('title', "$customGroup"); | |
356 | $this->select('extends[0]', "value=Contact"); | |
357 | $this->click('_qf_Group_next-bottom'); | |
358 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); | |
0bd37c06 | 359 | $this->assertElementContainsText("crm-notification-container", $customGroup); |
6a488035 TO |
360 | |
361 | // Add custom fields | |
362 | $field1 = "Checkbox $title"; | |
363 | $this->type('label', $field1); | |
364 | $this->select('data_type[1]', "value=CheckBox"); | |
365 | $this->waitForElementPresent('option_label_2'); | |
366 | ||
367 | // add multiple choice options | |
368 | $label1 = "Check $title One"; | |
369 | $value1 = 1; | |
370 | $this->type('option_label_1', $label1); | |
371 | $this->type('option_value_1', $value1); | |
372 | ||
373 | $label2 = "Check $title Two"; | |
374 | $value2 = 2; | |
375 | $this->type('option_label_2', $label2); | |
376 | $this->type('option_value_2', $value2); | |
377 | ||
378 | $this->click("link=another choice"); | |
379 | ||
380 | $label3 = "Check $title Three"; | |
381 | $value3 = 3; | |
382 | $this->type('option_label_3', $label3); | |
383 | $this->type('option_value_3', $value3); | |
384 | ||
385 | $this->click('_qf_Field_next-bottom'); | |
386 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
0bd37c06 | 387 | $this->assertElementContainsText("crm-notification-container", $field1); |
6a488035 TO |
388 | |
389 | // Create a profile for survey | |
390 | $this->openCiviPage("admin/uf/group", "reset=1"); | |
391 | ||
392 | $this->click("link=Add Profile"); | |
393 | $this->waitForElementPresent('_qf_Group_cancel-bottom'); | |
394 | ||
395 | $surveyProfile = "Survey Profile $title"; | |
396 | $this->type('title', $surveyProfile); | |
397 | $this->click('_qf_Group_next-bottom'); | |
398 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); | |
0bd37c06 | 399 | $this->assertElementContainsText("crm-notification-container", $surveyProfile); |
6a488035 TO |
400 | |
401 | // Add fields to the profile | |
402 | // Phone ( Primary ) | |
403 | $this->select('field_name[0]', "value=Contact"); | |
404 | $this->select('field_name[1]', "value=phone"); | |
405 | $this->click('field_name[1]'); | |
406 | $this->select('visibility', "value=Public Pages and Listings"); | |
407 | $this->check('is_searchable'); | |
408 | $this->check('in_selector'); | |
409 | $this->click('_qf_Field_next_new-bottom'); | |
410 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
411 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); | |
412 | ||
413 | // Custom Data Fields | |
414 | $this->select('field_name[0]', "value=Contact"); | |
415 | $this->select('field_name[1]', "label=$field1 :: $customGroup"); | |
416 | $this->click('field_name[1]'); | |
417 | $this->select('visibility', "value=Public Pages and Listings"); | |
418 | $this->check('is_searchable'); | |
419 | $this->check('in_selector'); | |
420 | $this->click('_qf_Field_next-bottom'); | |
421 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
422 | ||
423 | // Enable CiviCampaign module if necessary | |
0bd37c06 | 424 | $this->enableComponents(array('CiviCampaign')); |
6a488035 TO |
425 | |
426 | // add the required Drupal permission | |
427 | $permissions = array('edit-2-administer-civicampaign'); | |
428 | $this->changePermissions($permissions); | |
429 | ||
430 | // Create a survey | |
431 | $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom"); | |
432 | ||
433 | // fill in a unique title for the survey | |
434 | $surveyTitle = "Survey $title"; | |
435 | $this->type('title', $surveyTitle); | |
436 | ||
437 | // select the created campaign | |
438 | //$this->select("campaign_id", "label=Campaign $title"); | |
439 | ||
440 | // select the activity type | |
441 | $this->select("activity_type_id", "label=Survey"); | |
442 | ||
443 | // fill in reserve survey respondents | |
444 | $this->type("default_number_of_contacts", 50); | |
445 | ||
446 | // fill in interview survey respondents | |
447 | $this->type("max_number_of_contacts", 100); | |
448 | ||
449 | // release frequency | |
450 | $this->type("release_frequency", 2); | |
451 | ||
452 | $this->click("_qf_Main_upload-bottom"); | |
453 | $this->waitForElementPresent("_qf_Questions_upload_next-bottom"); | |
454 | ||
455 | //Select the profile for the survey | |
456 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual"); | |
457 | ||
458 | // select the question created for the survey | |
459 | $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=$surveyProfile"); | |
460 | $this->click("_qf_Questions_upload_next-bottom"); | |
461 | ||
462 | // create a set of options for Survey Responses _qf_Results_upload_done-bottom | |
463 | $this->waitForElementPresent('_qf_Results_upload_done-bottom'); | |
464 | $optionLabel1 = "Label $title 1"; | |
465 | $this->type("//input[@id='option_label_1']", "$optionLabel1"); | |
466 | $this->type("//input[@id='option_value_1']", "1"); | |
467 | ||
468 | $optionLabel2 = "Label $title 2"; | |
469 | $this->type("//input[@id='option_label_2']", "$optionLabel2"); | |
470 | $this->type("//input[@id='option_value_2']", "2"); | |
471 | $this->type("//input[@id='report_title']", "Survey $title"); | |
472 | $this->click('_qf_Results_upload_done-bottom'); | |
473 | $this->waitForElementPresent("//div[@id='search_form_survey']"); | |
474 | $this->assertTrue($this->isTextPresent("'Results' have been saved."), | |
475 | "Status message didn't show up after saving survey!" | |
476 | ); | |
477 | ||
478 | // Reserve Respondents | |
479 | $this->openCiviPage("survey/search", "reset=1&op=reserve", '_qf_Search_refresh'); | |
480 | ||
481 | // search for the respondents | |
482 | // select survey | |
483 | $this->select('campaign_survey_id', "label=$surveyTitle"); | |
484 | ||
485 | // need to wait for Groups field to reload dynamically | |
0bd37c06 | 486 | $this->waitForElementPresent("//select[@class='campaignGroupsSelect']/option[text()='$groupName']"); |
6a488035 TO |
487 | |
488 | // select group | |
489 | $this->click('campaignGroupsSelect1'); | |
490 | $this->select('campaignGroupsSelect1', "label=$groupName"); | |
491 | $this->click('_qf_Search_refresh'); | |
492 | ||
493 | $this->waitForElementPresent('_qf_Search_next_print'); | |
494 | $this->click("CIVICRM_QFID_ts_all_4"); | |
495 | $this->click("Go"); | |
496 | $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom'); | |
497 | ||
498 | $this->click('_qf_Reserve_done_reserve-bottom'); | |
499 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
500 | // wait for Access Keys div to appear at bottom of page - since this page may take a while | |
501 | $this->waitForElementPresent('access'); | |
0bd37c06 | 502 | $this->assertElementContainsText("crm-notification-container", "2"); |
6a488035 TO |
503 | |
504 | $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit'); | |
505 | ||
506 | // Select columns to be displayed | |
507 | $this->check('fields[survey_id]'); | |
508 | $this->check('fields[survey_response]'); | |
509 | $this->select('survey_id_value', "label=$surveyTitle"); | |
510 | $this->select('status_id_value', "label=Reserved"); | |
511 | $this->click('_qf_SurveyDetails_submit'); | |
512 | $this->waitForElementPresent('_qf_SurveyDetails_submit_print'); | |
513 | $this->assertTrue($this->isTextPresent("Is equal to Reserved")); | |
514 | ||
515 | // commenting out the print assertion as print dialog which appears breaks the webtest | |
516 | // as it is OS-related and cannot be handled through webtest | |
517 | ||
518 | // $this->click('_qf_SurveyDetails_submit_print'); | |
519 | // $this->waitForPageToLoad($this->getTimeoutMsec()); | |
520 | ||
521 | // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle")); | |
522 | // $this->assertTrue($this->isTextPresent("Q1 = $field1")); | |
523 | // $this->assertTrue($this->isTextPresent("$value1 | $value2 | $value3")); | |
524 | ||
525 | // Interview Respondents | |
526 | $this->openCiviPage("survey/search", "reset=1&op=interview", '_qf_Search_refresh'); | |
527 | ||
528 | // search for the respondents | |
529 | // select survey | |
530 | $this->select('campaign_survey_id', "label=$surveyTitle"); | |
531 | ||
532 | // need to wait for Groups field to reload dynamically | |
0bd37c06 | 533 | $this->waitForElementPresent("//select[@class='campaignGroupsSelect']/option[text()='$groupName']"); |
6a488035 TO |
534 | |
535 | // select group | |
536 | $this->click('campaignGroupsSelect1'); | |
537 | $this->select('campaignGroupsSelect1', "label=$groupName"); | |
538 | $this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li"); | |
539 | $this->click('_qf_Search_refresh'); | |
540 | ||
541 | $this->waitForElementPresent('_qf_Search_next_print'); | |
542 | $this->click("xpath=//table[@class='selector']/tbody//tr[@id='rowid{$id1}']/td[1]"); | |
543 | $this->click("mark_x_{$id1}"); | |
544 | $this->click("Go"); | |
545 | $this->waitForElementPresent('_qf_Interview_cancel_interview'); | |
546 | ||
547 | $this->type("field_{$id1}_phone-Primary-1", 9876543210); | |
0bd37c06 CW |
548 | $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[2]/../label[text()='$label1']"); |
549 | $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[6]/../label[text()='$label2']"); | |
6a488035 TO |
550 | $this->select("field_{$id1}_result", $optionLabel1); |
551 | $this->click("interview_voter_button_{$id1}"); | |
552 | sleep(3); | |
553 | // Survey Report | |
554 | $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit'); | |
555 | ||
556 | // Select columns to be displayed | |
557 | $this->check('fields[survey_id]'); | |
558 | $this->check('fields[survey_response]'); | |
559 | $this->select('survey_id_value', "label=$surveyTitle"); | |
560 | $this->select('status_id_value', "label=Interviewed"); | |
561 | $this->click('_qf_SurveyDetails_submit'); | |
562 | $this->waitForElementPresent('_qf_SurveyDetails_submit_print'); | |
563 | $this->assertTrue($this->isTextPresent("Is equal to Interviewed")); | |
564 | ||
565 | // commenting out the print assertion as print dialog which appears breaks the webtest | |
566 | // as it is OS-related and cannot be handled through webtest | |
567 | ||
568 | // $this->click('_qf_SurveyDetails_submit_print'); | |
569 | // $this->waitForPageToLoad($this->getTimeoutMsec()); | |
570 | ||
571 | // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle")); | |
572 | // $this->assertTrue($this->isTextPresent("Q1 = $field1")); | |
573 | // $this->assertTrue($this->isTextPresent("$value1")); | |
574 | ||
575 | // use GOTV (campaign/gotv) to mark the respondents as voted | |
576 | $this->openCiviPage("campaign/gotv", "reset=1"); | |
577 | ||
578 | // search for the respondents | |
579 | // select survey | |
580 | $this->select('campaign_survey_id', "label=$surveyTitle"); | |
581 | // need to wait for Groups field to reload dynamically | |
0bd37c06 | 582 | $this->waitForElementPresent("//select[@class='campaignGroupsSelect']/option[text()='$groupName']"); |
6a488035 TO |
583 | |
584 | // select group | |
585 | $this->click('campaignGroupsSelect1'); | |
586 | $this->select('campaignGroupsSelect1', "label=$groupName"); | |
587 | $this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li"); | |
588 | $this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='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 | ||
599 | $this->verifyText("xpath=//table[@class='selector']/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]", | |
600 | preg_quote("$surveyTitle - Respondent Interview") | |
601 | ); | |
602 | $this->verifyText("xpath=//table[@class='selector']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]", | |
603 | preg_quote("$surveyTitle - Respondent Reservation") | |
604 | ); | |
605 | } | |
606 | } | |
607 |