Merge pull request #11813 from seanmadsen/add-survey-pre-post-hooks
[civicrm-core.git] / tests / phpunit / WebTest / Campaign / SurveyUsageScenarioTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Campaign_SurveyUsageScenarioTest
31 */
32 class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testSurveyUsageScenario() {
39 $this->webtestLogin('admin');
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");
52 $this->waitForElementPresent("css=#group_id option");
53
54 // add to group
55 $this->select("group_id", "label=$groupName");
56 $this->click("_qf_GroupContact_next");
57 $this->waitForElementPresent('link=Remove');
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");
65 $this->waitForElementPresent("css=#group_id option");
66
67 // add to group
68 $this->select("group_id", "label=$groupName");
69 $this->click("_qf_GroupContact_next");
70 $this->waitForElementPresent('link=Remove');
71
72 // Enable CiviCampaign module if necessary
73 $this->enableComponents(array('CiviCampaign'));
74
75 // add the required permission
76 $this->changePermissions(array('edit-2-administer-civicampaign'));
77
78 // Log in as normal user
79 $this->webtestLogin();
80
81 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
82 $this->waitForElementPresent('title');
83 $this->type("title", "Campaign $title");
84
85 // select the campaign type
86 $this->waitForElementPresent('campaign_type_id');
87 $this->select("campaign_type_id", "value=2");
88
89 // fill in the description
90 $this->type("description", "This is a test campaign");
91
92 // include groups for the campaign
93 $this->addSelection("includeGroups", "label=$groupName");
94 $this->click("//option[@value=4]");
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
106 $this->waitForText('crm-notification-container', "$title");
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");
120 $this->waitForPageToLoad($this->getTimeoutMsec());
121
122 // add a custom field to the custom group
123 $this->waitForElementPresent('label');
124 $this->type("label", "Field $title");
125
126 $this->select("data_type[1]", "value=Radio");
127
128 $this->waitForElementPresent("option_label_1");
129
130 // create a set of options
131 $this->type("option_label_1", "Option $title 1");
132 $this->type("option_value_1", "1");
133
134 $this->type("option_label_2", "Option $title 2");
135 $this->type("option_value_2", "2");
136
137 // save the custom field
138 $this->click("_qf_Field_done-bottom");
139
140 $this->waitForElementPresent("newCustomField");
141 $this->waitForText('crm-notification-container', "$title");
142
143 // create a profile for campaign
144 $this->openCiviPage("admin/uf/group/add", "action=add&reset=1", "_qf_Group_next-bottom");
145
146 // fill in a unique title for the profile
147 $this->type("title", "Profile $title");
148
149 // save the profile
150 $this->click("_qf_Group_next-bottom");
151
152 $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
153 $this->click("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
154
155 // add a profile field for activity
156 $this->waitForElementPresent('field_name[0]');
157 $this->select("field_name[0]", "value=Activity");
158 $this->waitForElementPresent("field_name[1]");
159 $this->select("field_name[1]", "label=Field $title :: Group $title");
160
161 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
162 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
163 $this->waitForText('crm-notification-container', "$title");
164
165 // create a survey
166 $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom");
167
168 // fill in a unique title for the survey
169 $this->type("title", "Survey $title");
170
171 // select the created campaign
172 $this->select("campaign_id", "label=Campaign $title");
173
174 // select the activity type
175 $this->select("activity_type_id", "label=Survey");
176
177 // fill in reserve survey respondents
178 $this->type("default_number_of_contacts", 50);
179
180 // fill in interview survey respondents
181 $this->type("max_number_of_contacts", 100);
182
183 // release frequency
184 $this->type("release_frequency", 2);
185
186 $this->click("_qf_Main_upload-bottom");
187 $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
188
189 // Select the profile for the survey
190 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
191
192 // select the question created for the survey
193
194 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=Profile $title");
195 $this->click("_qf_Questions_upload_next-bottom");
196
197 // create a set of options for Survey Responses _qf_Results_upload_done-bottom
198 $this->waitForElementPresent('_qf_Results_upload_done-bottom');
199 $this->type("//input[@id='option_label_1']", "Label $title 1");
200 $this->type("//input[@id='option_value_1']", "1");
201
202 $this->type("//input[@id='option_label_2']", "Label $title 2");
203 $this->type("//input[@id='option_value_2']", "2");
204 $this->click('_qf_Results_upload_done-bottom');
205 $this->waitForElementPresent("//div[@id='search_form_survey']");
206 $this->waitForText('crm-notification-container', "Results");
207
208 // Reserve Respondents
209 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
210
211 // search for the respondents
212 $this->select("campaign_survey_id", "label=Survey $title");
213
214 $this->click("_qf_Search_refresh");
215 $this->waitForElementPresent('toggleSelect');
216 $this->click('toggleSelect');
217 $this->select('task', "Reserve Respondents");
218
219 $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
220 $this->click("_qf_Reserve_done_reserve-bottom");
221 $this->waitForPageToLoad($this->getTimeoutMsec());
222 $this->waitForText('crm-notification-container', "2 contacts have been reserved.");
223
224 // Interview Respondents
225 $this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh");
226 // search for the respondents
227 $this->waitForElementPresent('campaign_survey_id');
228 $this->select("campaign_survey_id", "label=Survey $title");
229 $this->click("_qf_Search_refresh");
230
231 $this->waitForElementPresent('toggleSelect');
232 $this->click("xpath=//table[@class='selector row-highlight']/thead/tr/th[1]/input[@id='toggleSelect']");
233 $this->select('task', "Record Survey Responses");
234 $this->waitForElementPresent("_qf_Interview_cancel_interview");
235 $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[@class='result']/select", "value=Label $title 1");
236 $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[9]/a[1]");
237
238 $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[@class='result']/select", "value=Label $title 2");
239 $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[9]/a[1]");
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 $id = $this->urlArg('cid');
247 $sortName3 = "James, $firstName3";
248
249 // add contact to group
250 // visit group tab
251 $this->click("css=li#tab_group a");
252 $this->waitForElementPresent("css=#group_id option");
253
254 // add to group
255 $this->select("group_id", "label=$groupName");
256 $this->click("_qf_GroupContact_next");
257 $this->waitForElementPresent('link=Remove');
258
259 // Reserve Respondents
260 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
261
262 // search for the respondents
263 $this->select("campaign_survey_id", "label=Survey $title");
264
265 $this->click("_qf_Search_refresh");
266 $this->waitForElementPresent('toggleSelect');
267 $this->click('toggleSelect');
268 $this->waitForElementPresent('task');
269 $this->select('task', "Reserve Respondents");
270 $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
271 $this->click("_qf_Reserve_done_reserve-bottom");
272 $this->waitForText('crm-notification-container', "1 contact has been reserved.");
273
274 // Release Respondents
275 $this->openCiviPage("survey/search", "reset=1&op=release", "_qf_Search_refresh");
276
277 // search for the respondents
278 $this->select("campaign_survey_id", "label=Survey $title");
279
280 $this->click("_qf_Search_refresh");
281 $this->waitForElementPresent('toggleSelect');
282 $this->click('toggleSelect');
283 $this->waitForElementPresent('task');
284 $this->select("task", "label=Release Respondents");
285 $this->waitForElementPresent('_qf_Release_done-bottom');
286 $this->click("_qf_Release_done-bottom");
287 $this->waitForText('crm-notification-container', "released");
288
289 // check whether contact is available for reserving again
290 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
291
292 // search for the respondents
293 $this->select("campaign_survey_id", "label=Survey $title");
294
295 $this->waitForElementPresent('_qf_Search_refresh');
296 $this->clickLink("_qf_Search_refresh");
297 $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", '1 Result');
298 }
299
300 public function testSurveyReportTest() {
301 $this->markTestSkipped('Skipping for now as it works fine locally.');
302 $this->webtestLogin('admin');
303
304 // Enable CiviCampaign module if necessary
305 $this->enableComponents(array('CiviCampaign'));
306
307 // add the required permission
308 $this->changePermissions('edit-2-administer-civicampaign');
309
310 $this->webtestLogin();
311
312 // Create new group
313 $title = substr(sha1(rand()), 0, 7);
314 $groupName = $this->WebtestAddGroup();
315
316 // Adding contact
317 $firstName1 = substr(sha1(rand()), 0, 7);
318 $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
319 $id1 = $this->urlArg('cid');
320
321 // add contact to group
322 // visit group tab
323 $this->click("css=li#tab_group a");
324 $this->waitForElementPresent('css=#group_id option');
325
326 // add to group
327 $this->select("group_id", "label=$groupName");
328 $this->click("_qf_GroupContact_next");
329 $this->waitForElementPresent('link=Remove');
330
331 $firstName2 = substr(sha1(rand()), 0, 7);
332 $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
333 $id2 = $this->urlArg('cid');
334
335 // add contact to group
336 // visit group tab
337 $this->click("css=li#tab_group a");
338 $this->waitForElementPresent('css=#group_id option');
339
340 // add to group
341 $this->select("group_id", "label=$groupName");
342 $this->click("_qf_GroupContact_next");
343 $this->waitForElementPresent('link=Remove');
344
345 // Create custom group and add custom data fields
346 $this->openCiviPage("admin/custom/group", "reset=1");
347
348 $this->click("link=Add Set of Custom Fields");
349 $this->waitForElementPresent('_qf_Group_cancel-bottom');
350
351 $customGroup = "Custom Group $title";
352 $this->type('title', "$customGroup");
353 $this->select('extends[0]', "value=Contact");
354 $this->clickLink('_qf_Group_next-bottom');
355 $this->waitForText('crm-notification-container', $customGroup);
356
357 // Add custom fields
358 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
359 $field1 = "Checkbox $title";
360 $this->type('label', $field1);
361 $this->select('data_type[1]', "value=CheckBox");
362 $this->waitForElementPresent('option_label_2');
363
364 // add multiple choice options
365 $label1 = "Check $title One";
366 $value1 = 1;
367 $this->type('option_label_1', $label1);
368 $this->type('option_value_1', $value1);
369
370 $label2 = "Check $title Two";
371 $value2 = 2;
372 $this->type('option_label_2', $label2);
373 $this->type('option_value_2', $value2);
374
375 $this->click("link=another choice");
376
377 $label3 = "Check $title Three";
378 $value3 = 3;
379 $this->type('option_label_3', $label3);
380 $this->type('option_value_3', $value3);
381
382 $this->click("xpath=//*[@id='_qf_Field_done-bottom']");
383 $this->waitForElementPresent('newCustomField');
384 $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span[text()='{$field1}']");
385
386 // Create a profile for survey
387 $this->openCiviPage("admin/uf/group", "reset=1");
388
389 $this->click("link=Add Profile");
390 $this->waitForElementPresent('_qf_Group_cancel-bottom');
391
392 $surveyProfile = "Survey Profile $title";
393 $this->type('title', $surveyProfile);
394 $this->click('_qf_Group_next-bottom');
395 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '$surveyProfile' has been added. You can add fields to this profile now.");
396
397 // Add fields to the profile
398 // Phone ( Primary )
399 $this->waitForElementPresent('field_name[0]');
400 $this->select('field_name[0]', "value=Contact");
401 $this->waitForElementPresent('field_name[1]');
402 $this->select('field_name[1]', "value=phone");
403 $this->click('field_name[1]');
404 $this->select('visibility', "value=Public Pages and Listings");
405 $this->check('is_searchable');
406 $this->check('in_selector');
407 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
408 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
409
410 // Custom Data Fields
411 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
412 $this->waitForElementPresent('field_name[0]');
413 $this->select('field_name[0]', "value=Contact");
414 $this->waitForElementPresent('field_name[1]');
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("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
421 $this->waitForElementPresent("xpath=//table[@id='options']");
422 $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span", $field1);
423
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->waitForElementPresent('title');
430 $this->type('title', $surveyTitle);
431
432 // select the created campaign
433 //$this->select("campaign_id", "label=Campaign $title");
434
435 // select the activity type
436 $this->waitForElementPresent('activity_type_id');
437 $this->select("activity_type_id", "label=Survey");
438
439 // fill in reserve survey respondents
440 $this->type("default_number_of_contacts", 50);
441
442 // fill in interview survey respondents
443 $this->type("max_number_of_contacts", 100);
444
445 // release frequency
446 $this->waitForElementPresent('release_frequency');
447 $this->type("release_frequency", 2);
448
449 $this->click("_qf_Main_upload-bottom");
450 $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
451
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
455 // select the question created for the survey
456
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
484 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
485
486 // select group
487 $this->waitForElementPresent('group');
488 $this->click('group');
489 $this->waitForElementPresent('group');
490 $this->select('group', "label=$groupName");
491 $this->click('_qf_Search_refresh');
492
493 $this->waitForElementPresent('toggleSelect');
494 $this->click('toggleSelect');
495 $this->select('task', "Reserve Respondents");
496
497 $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom');
498
499 $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access');
500 $this->waitForText('crm-notification-container', "2 contacts have been reserved.");
501
502 $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
503
504 // Select columns to be displayed
505 $this->check('fields[survey_id]');
506 $this->check('fields[survey_response]');
507 $this->select('survey_id_value', "label=$surveyTitle");
508 $this->select('status_id_value', "label=Reserved");
509 $this->click('_qf_SurveyDetails_submit');
510 $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
511 $this->assertTrue($this->isTextPresent("Is equal to Reserved"));
512
513 // commenting out the print assertion as print dialog which appears breaks the webtest
514 // as it is OS-related and cannot be handled through webtest
515
516 // $this->click('_qf_SurveyDetails_submit_print');
517 // $this->waitForPageToLoad($this->getTimeoutMsec());
518
519 // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
520 // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
521 // $this->assertTrue($this->isTextPresent("$value1 | $value2 | $value3"));
522
523 // Interview Respondents
524 $this->openCiviPage("survey/search", "reset=1&op=interview", '_qf_Search_refresh');
525
526 // search for the respondents
527 // select survey
528 $this->select('campaign_survey_id', "label=$surveyTitle");
529
530 // need to wait for Groups field to reload dynamically
531 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
532
533 // select group
534 $this->click('group');
535 $this->select('group', "label=$groupName");
536 //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
537 $this->click('_qf_Search_refresh');
538
539 //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]");
540 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
541 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
542 $this->waitForElementPresent('task');
543 $this->select('task', "Record Survey Responses");
544 $this->waitForElementPresent('_qf_Interview_cancel_interview');
545
546 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[6]/input[@type='text']");
547
548 $this->type("field_{$id1}_phone-Primary-1", 9876543210);
549
550 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
551 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
552 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
553 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
554
555 $this->select("field_{$id1}_result", $optionLabel1);
556 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[10]/a");
557 $this->click('_qf_Interview_cancel_interview');
558 // Because it tends to cause problems, all uses of sleep() must be justified in comments
559 // Sleep should never be used for wait for anything to load from the server
560 // Justification for this instance: FIXME
561 $this->waitForAjaxContent();
562 // Survey Report
563 $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
564
565 // Select columns to be displayed
566 $this->check('fields[survey_id]');
567 $this->check('fields[survey_response]');
568 $this->select('survey_id_value', "label=$surveyTitle");
569 $this->select('status_id_value', "label=Interviewed");
570 $this->click('_qf_SurveyDetails_submit');
571 $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
572 $this->assertTrue($this->isTextPresent("Is equal to Interviewed"));
573
574 // commenting out the print assertion as print dialog which appears breaks the webtest
575 // as it is OS-related and cannot be handled through webtest
576
577 // $this->click('_qf_SurveyDetails_submit_print');
578 // $this->waitForPageToLoad($this->getTimeoutMsec());
579
580 // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
581 // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
582 // $this->assertTrue($this->isTextPresent("$value1"));
583
584 // use GOTV (campaign/gotv) to mark the respondents as voted
585 $this->openCiviPage("campaign/gotv", "reset=1");
586
587 // search for the respondents
588 // select survey
589 $this->select('campaign_survey_id', "label=$surveyTitle");
590 // need to wait for Groups field to reload dynamically
591 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
592
593 // select group
594 $this->click('group');
595 $this->select('group', "label=$groupName");
596 //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
597 //$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']");
598 $this->click("link=Search");
599
600 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
601 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
602
603 // Check title of the activities created
604 $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
605 $this->waitForElementPresent('activity_survey_id');
606 $this->select('activity_survey_id', "label=$surveyTitle");
607 $this->click('_qf_Search_refresh');
608 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
609 $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]",
610 preg_quote("$surveyTitle - Respondent Interview")
611 );
612 $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]",
613 preg_quote("$surveyTitle - Respondent Reservation")
614 );
615 }
616
617 }