version fixes
[civicrm-core.git] / tests / phpunit / WebTest / Campaign / SurveyUsageScenarioTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
81621fee 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
d25dd0ee 25 */
6a488035 26
6a488035 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Campaign_SurveyUsageScenarioTest
31 */
6a488035
TO
32class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
00be9182 38 public 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 81 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
9a24315b 82 $this->waitForElementPresent('title');
6a488035
TO
83 $this->type("title", "Campaign $title");
84
85 // select the campaign type
9a24315b 86 $this->waitForElementPresent('campaign_type_id');
6a488035
TO
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
9a24315b 93 $this->addSelection("includeGroups", "label=$groupName");
6a488035 94 $this->click("//option[@value=4]");
6a488035
TO
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
9a24315b 123 $this->waitForElementPresent('label');
6a488035
TO
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
9a24315b 138 $this->click("_qf_Field_done-bottom");
6a488035
TO
139
140 $this->waitForElementPresent("newCustomField");
6c5f7368 141 $this->waitForText('crm-notification-container', "$title");
6a488035
TO
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
9a24315b
RK
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");
6a488035
TO
154
155 // add a profile field for activity
9a24315b 156 $this->waitForElementPresent('field_name[0]');
6a488035
TO
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
9a24315b
RK
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]");
6c5f7368 163 $this->waitForText('crm-notification-container', "$title");
6a488035
TO
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");
76e86fd8 188
0bd37c06 189 // Select the profile for the survey
6a488035
TO
190 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
191
76e86fd8
CW
192 // select the question created for the survey
193
6a488035
TO
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']");
6c5f7368 206 $this->waitForText('crm-notification-container', "Results");
6a488035
TO
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");
9a24315b
RK
215 $this->waitForElementPresent('toggleSelect');
216 $this->click('toggleSelect');
642aa483 217 $this->select('task', "Reserve Respondents");
6a488035
TO
218
219 $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
220 $this->click("_qf_Reserve_done_reserve-bottom");
221 $this->waitForPageToLoad($this->getTimeoutMsec());
0391e7ab 222 $this->waitForText('crm-notification-container', "2 contacts have been reserved.");
6a488035
TO
223
224 // Interview Respondents
225 $this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh");
6a488035 226 // search for the respondents
9a24315b 227 $this->waitForElementPresent('campaign_survey_id');
6a488035 228 $this->select("campaign_survey_id", "label=Survey $title");
6a488035
TO
229 $this->click("_qf_Search_refresh");
230
9a24315b
RK
231 $this->waitForElementPresent('toggleSelect');
232 $this->click('toggleSelect');
233 $this->select('task', "Record Survey Responses");
6a488035
TO
234 $this->waitForElementPresent("_qf_Interview_cancel_interview");
235
236 $this->click("CIVICRM_QFID_1_2");
6c6e6187 237 $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[8]/select", "value=Label $title 1");
9a24315b 238 $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[9]/a");
6a488035
TO
239
240 $this->click("CIVICRM_QFID_2_8");
6a488035 241
6c6e6187 242 $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[8]/select", "value=Label $title 2");
9a24315b 243 $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[9]/a");
6a488035
TO
244 $this->click("_qf_Interview_cancel_interview");
245 $this->waitForPageToLoad($this->getTimeoutMsec());
246
247 // add a contact to the group to test release respondents
248 $firstName3 = substr(sha1(rand()), 0, 7);
249 $this->webtestAddContact($firstName3, "James", "$firstName3.james@example.org");
a471a3b6 250 $id = $this->urlArg('cid');
6a488035
TO
251 $sortName3 = "James, $firstName3";
252
253 // add contact to group
254 // visit group tab
255 $this->click("css=li#tab_group a");
0caa4679 256 $this->waitForElementPresent("css=#group_id option");
6a488035
TO
257
258 // add to group
259 $this->select("group_id", "label=$groupName");
260 $this->click("_qf_GroupContact_next");
642aa483 261 $this->waitForElementPresent('link=Remove');
6a488035
TO
262
263 // Reserve Respondents
264 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
265
266 // search for the respondents
267 $this->select("campaign_survey_id", "label=Survey $title");
268
269 $this->click("_qf_Search_refresh");
9a24315b
RK
270 $this->waitForElementPresent('toggleSelect');
271 $this->click('toggleSelect');
272 $this->waitForElementPresent('task');
642aa483 273 $this->select('task', "Reserve Respondents");
6a488035
TO
274 $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
275 $this->click("_qf_Reserve_done_reserve-bottom");
0391e7ab 276 $this->waitForText('crm-notification-container', "1 contact has 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");
9a24315b
RK
285 $this->waitForElementPresent('toggleSelect');
286 $this->click('toggleSelect');
287 $this->waitForElementPresent('task');
642aa483 288 $this->select("task", "label=Release Respondents");
9a24315b
RK
289 $this->waitForElementPresent('_qf_Release_done-bottom');
290 $this->click("_qf_Release_done-bottom");
6c5f7368 291 $this->waitForText('crm-notification-container', "released");
6a488035
TO
292
293 // check whether contact is available for reserving again
294 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
295
296 // search for the respondents
297 $this->select("campaign_survey_id", "label=Survey $title");
298
9a24315b 299 $this->waitForElementPresent('_qf_Search_refresh');
c3ad8633 300 $this->clickLink("_qf_Search_refresh");
6c6e6187 301 $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", '1 Result');
6a488035
TO
302 }
303
00be9182 304 public function testSurveyReportTest() {
42daf119
CW
305 $this->webtestLogin('admin');
306
307 // Enable CiviCampaign module if necessary
308 $this->enableComponents(array('CiviCampaign'));
309
310 // add the required permission
311 $this->changePermissions('edit-2-administer-civicampaign');
312
6a488035
TO
313 $this->webtestLogin();
314
315 // Create new group
316 $title = substr(sha1(rand()), 0, 7);
317 $groupName = $this->WebtestAddGroup();
318
319 // Adding contact
6a488035
TO
320 $firstName1 = substr(sha1(rand()), 0, 7);
321 $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
a471a3b6 322 $id1 = $this->urlArg('cid');
6a488035
TO
323
324 // add contact to group
325 // visit group tab
326 $this->click("css=li#tab_group a");
0caa4679 327 $this->waitForElementPresent('css=#group_id option');
6a488035
TO
328
329 // add to group
330 $this->select("group_id", "label=$groupName");
331 $this->click("_qf_GroupContact_next");
642aa483 332 $this->waitForElementPresent('link=Remove');
6a488035
TO
333
334 $firstName2 = substr(sha1(rand()), 0, 7);
335 $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
a471a3b6 336 $id2 = $this->urlArg('cid');
6a488035
TO
337
338 // add contact to group
339 // visit group tab
340 $this->click("css=li#tab_group a");
0caa4679 341 $this->waitForElementPresent('css=#group_id option');
6a488035
TO
342
343 // add to group
344 $this->select("group_id", "label=$groupName");
345 $this->click("_qf_GroupContact_next");
642aa483 346 $this->waitForElementPresent('link=Remove');
6a488035
TO
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");
75c2f9ab 357 $this->clickLink('_qf_Group_next-bottom');
6c5f7368 358 $this->waitForText('crm-notification-container', $customGroup);
6a488035
TO
359
360 // Add custom fields
fe725ccb 361 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
6a488035
TO
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
fe725ccb
RK
385 $this->click("xpath=//*[@id='_qf_Field_done-bottom']");
386 $this->waitForElementPresent('newCustomField');
387 $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span[text()='{$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');
75c2f9ab 398 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '$surveyProfile' has been added. You can add fields to this profile now.");
6a488035
TO
399
400 // Add fields to the profile
401 // Phone ( Primary )
fe725ccb 402 $this->waitForElementPresent('field_name[0]');
6a488035 403 $this->select('field_name[0]', "value=Contact");
fe725ccb 404 $this->waitForElementPresent('field_name[1]');
6a488035
TO
405 $this->select('field_name[1]', "value=phone");
406 $this->click('field_name[1]');
407 $this->select('visibility', "value=Public Pages and Listings");
408 $this->check('is_searchable');
409 $this->check('in_selector');
fe725ccb
RK
410 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
411 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
76e86fd8 412
6a488035 413 // Custom Data Fields
fe725ccb 414 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
75c2f9ab 415 $this->waitForElementPresent('field_name[0]');
6a488035 416 $this->select('field_name[0]', "value=Contact");
fe725ccb 417 $this->waitForElementPresent('field_name[1]');
6a488035
TO
418 $this->select('field_name[1]', "label=$field1 :: $customGroup");
419 $this->click('field_name[1]');
420 $this->select('visibility', "value=Public Pages and Listings");
421 $this->check('is_searchable');
422 $this->check('in_selector');
fe725ccb
RK
423 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
424 $this->waitForElementPresent("xpath=//table[@id='options']");
425 $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span", $field1);
6a488035 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";
fe725ccb 432 $this->waitForElementPresent('title');
6a488035
TO
433 $this->type('title', $surveyTitle);
434
435 // select the created campaign
436 //$this->select("campaign_id", "label=Campaign $title");
437
438 // select the activity type
fe725ccb 439 $this->waitForElementPresent('activity_type_id');
6a488035
TO
440 $this->select("activity_type_id", "label=Survey");
441
442 // fill in reserve survey respondents
443 $this->type("default_number_of_contacts", 50);
444
445 // fill in interview survey respondents
446 $this->type("max_number_of_contacts", 100);
447
448 // release frequency
449 $this->type("release_frequency", 2);
450
451 $this->click("_qf_Main_upload-bottom");
452 $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
76e86fd8 453
6a488035
TO
454 //Select the profile for the survey
455 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
456
76e86fd8
CW
457 // select the question created for the survey
458
6a488035
TO
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
642aa483 486 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
6a488035
TO
487
488 // select group
fe725ccb 489 $this->waitForElementPresent('group');
642aa483 490 $this->click('group');
fe725ccb 491 $this->waitForElementPresent('group');
642aa483 492 $this->select('group', "label=$groupName");
6a488035
TO
493 $this->click('_qf_Search_refresh');
494
fe725ccb
RK
495 $this->waitForElementPresent('toggleSelect');
496 $this->click('toggleSelect');
642aa483 497 $this->select('task', "Reserve Respondents");
fe725ccb 498
6a488035
TO
499 $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom');
500
225a8648 501 $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access');
0391e7ab 502 $this->waitForText('crm-notification-container', "2 contacts have been reserved.");
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
76e86fd8 516 // as it is OS-related and cannot be handled through webtest
6a488035
TO
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
642aa483 533 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
6a488035
TO
534
535 // select group
642aa483
AS
536 $this->click('group');
537 $this->select('group', "label=$groupName");
538 //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
6a488035
TO
539 $this->click('_qf_Search_refresh');
540
642aa483 541 //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]");
fe725ccb
RK
542 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
543 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
544 $this->waitForElementPresent('task');
545 $this->select('task', "Record Survey Responses");
6a488035
TO
546 $this->waitForElementPresent('_qf_Interview_cancel_interview');
547
48b420d7 548 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[6]/input[@type='text']");
fe725ccb 549
6a488035 550 $this->type("field_{$id1}_phone-Primary-1", 9876543210);
fe725ccb 551
75c2f9ab
RK
552 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
553 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
554 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
555 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
fe725ccb 556
6a488035 557 $this->select("field_{$id1}_result", $optionLabel1);
fe725ccb
RK
558 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[10]/a");
559 $this->click('_qf_Interview_cancel_interview');
efb29358
CW
560 // Because it tends to cause problems, all uses of sleep() must be justified in comments
561 // Sleep should never be used for wait for anything to load from the server
562 // Justification for this instance: FIXME
6a488035
TO
563 sleep(3);
564 // Survey Report
565 $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
566
567 // Select columns to be displayed
568 $this->check('fields[survey_id]');
569 $this->check('fields[survey_response]');
570 $this->select('survey_id_value', "label=$surveyTitle");
571 $this->select('status_id_value', "label=Interviewed");
572 $this->click('_qf_SurveyDetails_submit');
573 $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
574 $this->assertTrue($this->isTextPresent("Is equal to Interviewed"));
575
576 // commenting out the print assertion as print dialog which appears breaks the webtest
76e86fd8 577 // as it is OS-related and cannot be handled through webtest
6a488035
TO
578
579 // $this->click('_qf_SurveyDetails_submit_print');
580 // $this->waitForPageToLoad($this->getTimeoutMsec());
581
582 // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
583 // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
584 // $this->assertTrue($this->isTextPresent("$value1"));
585
586 // use GOTV (campaign/gotv) to mark the respondents as voted
587 $this->openCiviPage("campaign/gotv", "reset=1");
588
589 // search for the respondents
590 // select survey
591 $this->select('campaign_survey_id', "label=$surveyTitle");
592 // need to wait for Groups field to reload dynamically
642aa483 593 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
6a488035
TO
594
595 // select group
642aa483
AS
596 $this->click('group');
597 $this->select('group', "label=$groupName");
598 //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
599 //$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']");
600 $this->click("link=Search");
0bd37c06 601
fe725ccb
RK
602 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
603 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
6a488035
TO
604
605 // Check title of the activities created
606 $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
fe725ccb 607 $this->waitForElementPresent('activity_survey_id');
6a488035
TO
608 $this->select('activity_survey_id', "label=$surveyTitle");
609 $this->click('_qf_Search_refresh');
610 $this->waitForPageToLoad($this->getTimeoutMsec());
611
fe725ccb
RK
612 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
613 $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]",
6a488035
TO
614 preg_quote("$surveyTitle - Respondent Interview")
615 );
fe725ccb 616 $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]",
6a488035
TO
617 preg_quote("$surveyTitle - Respondent Reservation")
618 );
619 }
96025800 620
6a488035 621}