| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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('toggleSelect'); |
| 233 | $this->select('task', "Record Survey Responses"); |
| 234 | $this->waitForElementPresent("_qf_Interview_cancel_interview"); |
| 235 | |
| 236 | $this->click("CIVICRM_QFID_1_2"); |
| 237 | $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[8]/select", "value=Label $title 1"); |
| 238 | $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[9]/a"); |
| 239 | |
| 240 | $this->click("CIVICRM_QFID_2_8"); |
| 241 | |
| 242 | $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[8]/select", "value=Label $title 2"); |
| 243 | $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[9]/a"); |
| 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"); |
| 250 | $id = $this->urlArg('cid'); |
| 251 | $sortName3 = "James, $firstName3"; |
| 252 | |
| 253 | // add contact to group |
| 254 | // visit group tab |
| 255 | $this->click("css=li#tab_group a"); |
| 256 | $this->waitForElementPresent("css=#group_id option"); |
| 257 | |
| 258 | // add to group |
| 259 | $this->select("group_id", "label=$groupName"); |
| 260 | $this->click("_qf_GroupContact_next"); |
| 261 | $this->waitForElementPresent('link=Remove'); |
| 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"); |
| 270 | $this->waitForElementPresent('toggleSelect'); |
| 271 | $this->click('toggleSelect'); |
| 272 | $this->waitForElementPresent('task'); |
| 273 | $this->select('task', "Reserve Respondents"); |
| 274 | $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom"); |
| 275 | $this->click("_qf_Reserve_done_reserve-bottom"); |
| 276 | $this->waitForText('crm-notification-container', "1 contact has been reserved."); |
| 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 | $this->waitForElementPresent('toggleSelect'); |
| 286 | $this->click('toggleSelect'); |
| 287 | $this->waitForElementPresent('task'); |
| 288 | $this->select("task", "label=Release Respondents"); |
| 289 | $this->waitForElementPresent('_qf_Release_done-bottom'); |
| 290 | $this->click("_qf_Release_done-bottom"); |
| 291 | $this->waitForText('crm-notification-container', "released"); |
| 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 | |
| 299 | $this->waitForElementPresent('_qf_Search_refresh'); |
| 300 | $this->clickLink("_qf_Search_refresh"); |
| 301 | $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", '1 Result'); |
| 302 | } |
| 303 | |
| 304 | public function testSurveyReportTest() { |
| 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 | |
| 313 | $this->webtestLogin(); |
| 314 | |
| 315 | // Create new group |
| 316 | $title = substr(sha1(rand()), 0, 7); |
| 317 | $groupName = $this->WebtestAddGroup(); |
| 318 | |
| 319 | // Adding contact |
| 320 | $firstName1 = substr(sha1(rand()), 0, 7); |
| 321 | $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); |
| 322 | $id1 = $this->urlArg('cid'); |
| 323 | |
| 324 | // add contact to group |
| 325 | // visit group tab |
| 326 | $this->click("css=li#tab_group a"); |
| 327 | $this->waitForElementPresent('css=#group_id option'); |
| 328 | |
| 329 | // add to group |
| 330 | $this->select("group_id", "label=$groupName"); |
| 331 | $this->click("_qf_GroupContact_next"); |
| 332 | $this->waitForElementPresent('link=Remove'); |
| 333 | |
| 334 | $firstName2 = substr(sha1(rand()), 0, 7); |
| 335 | $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); |
| 336 | $id2 = $this->urlArg('cid'); |
| 337 | |
| 338 | // add contact to group |
| 339 | // visit group tab |
| 340 | $this->click("css=li#tab_group a"); |
| 341 | $this->waitForElementPresent('css=#group_id option'); |
| 342 | |
| 343 | // add to group |
| 344 | $this->select("group_id", "label=$groupName"); |
| 345 | $this->click("_qf_GroupContact_next"); |
| 346 | $this->waitForElementPresent('link=Remove'); |
| 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->clickLink('_qf_Group_next-bottom'); |
| 358 | $this->waitForText('crm-notification-container', $customGroup); |
| 359 | |
| 360 | // Add custom fields |
| 361 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]"); |
| 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("xpath=//*[@id='_qf_Field_done-bottom']"); |
| 386 | $this->waitForElementPresent('newCustomField'); |
| 387 | $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span[text()='{$field1}']"); |
| 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->waitForText('crm-notification-container', "Your CiviCRM Profile '$surveyProfile' has been added. You can add fields to this profile now."); |
| 399 | |
| 400 | // Add fields to the profile |
| 401 | // Phone ( Primary ) |
| 402 | $this->waitForElementPresent('field_name[0]'); |
| 403 | $this->select('field_name[0]', "value=Contact"); |
| 404 | $this->waitForElementPresent('field_name[1]'); |
| 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'); |
| 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]"); |
| 412 | |
| 413 | // Custom Data Fields |
| 414 | $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']"); |
| 415 | $this->waitForElementPresent('field_name[0]'); |
| 416 | $this->select('field_name[0]', "value=Contact"); |
| 417 | $this->waitForElementPresent('field_name[1]'); |
| 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'); |
| 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); |
| 426 | |
| 427 | // Create a survey |
| 428 | $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom"); |
| 429 | |
| 430 | // fill in a unique title for the survey |
| 431 | $surveyTitle = "Survey $title"; |
| 432 | $this->waitForElementPresent('title'); |
| 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 |
| 439 | $this->waitForElementPresent('activity_type_id'); |
| 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"); |
| 453 | |
| 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 | |
| 457 | // select the question created for the survey |
| 458 | |
| 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 |
| 486 | $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']"); |
| 487 | |
| 488 | // select group |
| 489 | $this->waitForElementPresent('group'); |
| 490 | $this->click('group'); |
| 491 | $this->waitForElementPresent('group'); |
| 492 | $this->select('group', "label=$groupName"); |
| 493 | $this->click('_qf_Search_refresh'); |
| 494 | |
| 495 | $this->waitForElementPresent('toggleSelect'); |
| 496 | $this->click('toggleSelect'); |
| 497 | $this->select('task', "Reserve Respondents"); |
| 498 | |
| 499 | $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom'); |
| 500 | |
| 501 | $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access'); |
| 502 | $this->waitForText('crm-notification-container', "2 contacts have been reserved."); |
| 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 |
| 533 | $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']"); |
| 534 | |
| 535 | // select group |
| 536 | $this->click('group'); |
| 537 | $this->select('group', "label=$groupName"); |
| 538 | //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li"); |
| 539 | $this->click('_qf_Search_refresh'); |
| 540 | |
| 541 | //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]"); |
| 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"); |
| 546 | $this->waitForElementPresent('_qf_Interview_cancel_interview'); |
| 547 | |
| 548 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[6]/input[@type='text']"); |
| 549 | |
| 550 | $this->type("field_{$id1}_phone-Primary-1", 9876543210); |
| 551 | |
| 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]"); |
| 556 | |
| 557 | $this->select("field_{$id1}_result", $optionLabel1); |
| 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'); |
| 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 |
| 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 |
| 577 | // as it is OS-related and cannot be handled through webtest |
| 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 |
| 593 | $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']"); |
| 594 | |
| 595 | // select group |
| 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"); |
| 601 | |
| 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"); |
| 604 | |
| 605 | // Check title of the activities created |
| 606 | $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh'); |
| 607 | $this->waitForElementPresent('activity_survey_id'); |
| 608 | $this->select('activity_survey_id', "label=$surveyTitle"); |
| 609 | $this->click('_qf_Search_refresh'); |
| 610 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 611 | |
| 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]", |
| 614 | preg_quote("$surveyTitle - Respondent Interview") |
| 615 | ); |
| 616 | $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]", |
| 617 | preg_quote("$surveyTitle - Respondent Reservation") |
| 618 | ); |
| 619 | } |
| 620 | |
| 621 | } |