| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.6 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
| 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_Event_MultiprofileEventTest |
| 31 | */ |
| 32 | class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { |
| 33 | |
| 34 | protected function setUp() { |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function testCreateEventRegisterPage() { |
| 39 | // Log in using webtestLogin() method |
| 40 | $this->webtestLogin(); |
| 41 | |
| 42 | $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7); |
| 43 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
| 44 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
| 45 | $participantfname = 'Dany' . substr(sha1(rand()), 0, 4); |
| 46 | $participantlname = 'Dan' . substr(sha1(rand()), 0, 4); |
| 47 | $email1 = $firstName . "@test.com"; |
| 48 | $email2 = $participantfname . "@test.com"; |
| 49 | |
| 50 | // Use default payment processor |
| 51 | $processorName = 'Test Processor'; |
| 52 | $this->webtestAddPaymentProcessor($processorName); |
| 53 | |
| 54 | //add email to name and address profile |
| 55 | $cfId = $this->_addEmailField(); |
| 56 | |
| 57 | // create custom group1 |
| 58 | $this->openCiviPage("admin/custom/group", "reset=1"); |
| 59 | $this->click("newCustomDataGroup"); |
| 60 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 61 | $this->type("title", $customGrp1); |
| 62 | $this->select("extends[0]", "value=Contact"); |
| 63 | $this->click("_qf_Group_next-bottom"); |
| 64 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 65 | |
| 66 | // get custom group id |
| 67 | $customGrpId1 = $this->urlArg('gid'); |
| 68 | |
| 69 | $customId = $this->_testGetCustomFieldId($customGrpId1); |
| 70 | |
| 71 | $profileId = $this->_testGetProfileId($customId); |
| 72 | |
| 73 | $this->openCiviPage("event/add", "reset=1&action=add"); |
| 74 | |
| 75 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); |
| 76 | $eventDescription = "Here is a description for this conference."; |
| 77 | $this->_testAddEventInfo($eventTitle, $eventDescription); |
| 78 | |
| 79 | $streetAddress = "100 Main Street"; |
| 80 | $this->_testAddLocation($streetAddress); |
| 81 | |
| 82 | $this->_testAddFees(FALSE, FALSE, $processorName); |
| 83 | |
| 84 | $eventPageId = $this->_testAddMultipleProfile($profileId); |
| 85 | |
| 86 | $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName, |
| 87 | $participantfname, $participantlname, $email1, $email2 |
| 88 | ); |
| 89 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 90 | |
| 91 | // Find Main Participant |
| 92 | $this->openCiviPage("event/search", "reset=1"); |
| 93 | $this->type("sort_name", $firstName); |
| 94 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 95 | $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE); |
| 96 | |
| 97 | $name = $firstName . " " . $lastName; |
| 98 | $status = 'Registered'; |
| 99 | |
| 100 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name)); |
| 101 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle)); |
| 102 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status)); |
| 103 | |
| 104 | // Find additional Participant |
| 105 | $this->openCiviPage("event/search", "reset=1"); |
| 106 | $this->type("sort_name", $participantfname); |
| 107 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 108 | $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE); |
| 109 | |
| 110 | $name = $participantfname . " " . $participantlname; |
| 111 | $status = 'Registered'; |
| 112 | |
| 113 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name)); |
| 114 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle)); |
| 115 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status)); |
| 116 | |
| 117 | // delete all custom data |
| 118 | if (isset($cfId)) { |
| 119 | $this->_removeEmailField($cfId); |
| 120 | } |
| 121 | foreach ($customId as $cid) { |
| 122 | $this->openCiviPage("admin/custom/group/field", "action=delete&reset=1&gid={$customGrpId1}&id=$cid"); |
| 123 | $this->click("_qf_DeleteField_next-bottom"); |
| 124 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 125 | } |
| 126 | $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=$customGrpId1"); |
| 127 | $this->click("_qf_DeleteGroup_next-bottom"); |
| 128 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 129 | } |
| 130 | |
| 131 | public function testAnoumyousRegisterPage() { |
| 132 | // add the required Drupal permission |
| 133 | $permission = array('edit-1-access-all-custom-data'); |
| 134 | $this->changePermissions($permission); |
| 135 | |
| 136 | $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7); |
| 137 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
| 138 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
| 139 | $participantfname = 'Dany' . substr(sha1(rand()), 0, 4); |
| 140 | $participantlname = 'Dan' . substr(sha1(rand()), 0, 4); |
| 141 | $email1 = $firstName . "@test.com"; |
| 142 | $email2 = $participantfname . "@test.com"; |
| 143 | $firstName2 = 'Man' . substr(sha1(rand()), 0, 4); |
| 144 | $lastName2 = 'Ann' . substr(sha1(rand()), 0, 7); |
| 145 | $participantfname2 = 'Adam' . substr(sha1(rand()), 0, 4); |
| 146 | $participantlname2 = 'Gil' . substr(sha1(rand()), 0, 4); |
| 147 | $email3 = $participantfname2 . "@test.com"; |
| 148 | $email4 = $firstName2 . "@test.com"; |
| 149 | |
| 150 | // Use default payment processor |
| 151 | $processorName = 'Test Processor'; |
| 152 | $this->webtestAddPaymentProcessor($processorName); |
| 153 | |
| 154 | //add email field to name and address profile |
| 155 | $cfId = $this->_addEmailField(); |
| 156 | |
| 157 | // create custom group1 |
| 158 | $this->openCiviPage("admin/custom/group", "reset=1"); |
| 159 | $this->click("newCustomDataGroup"); |
| 160 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 161 | $this->type("title", $customGrp1); |
| 162 | $this->select("extends[0]", "value=Contact"); |
| 163 | $this->click("_qf_Group_next-bottom"); |
| 164 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 165 | |
| 166 | // get custom group id |
| 167 | $customGrpId1 = $this->urlArg('gid'); |
| 168 | |
| 169 | $customId = $this->_testGetCustomFieldId($customGrpId1); |
| 170 | |
| 171 | $profileId = $this->_testGetProfileId($customId); |
| 172 | |
| 173 | $this->openCiviPage('event/add', "reset=1&action=add"); |
| 174 | |
| 175 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); |
| 176 | $eventDescription = "Here is a description for this conference."; |
| 177 | $this->_testAddEventInfo($eventTitle, $eventDescription); |
| 178 | |
| 179 | $streetAddress = "100 Main Street"; |
| 180 | $this->_testAddLocation($streetAddress); |
| 181 | |
| 182 | $this->_testAddFees(FALSE, FALSE, $processorName); |
| 183 | |
| 184 | $eventPageId = $this->_testAddMultipleProfile($profileId); |
| 185 | |
| 186 | // logout |
| 187 | $this->webtestLogout(); |
| 188 | |
| 189 | $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName, $participantfname, $participantlname, $email1, $email2); |
| 190 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 191 | // Log in using webtestLogin() method |
| 192 | $this->webtestLogin(); |
| 193 | |
| 194 | // Find Main Participant |
| 195 | $this->openCiviPage("event/search", "reset=1"); |
| 196 | $this->type("sort_name", $firstName); |
| 197 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 198 | $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE); |
| 199 | |
| 200 | $name = $firstName . " " . $lastName; |
| 201 | $status = 'Registered'; |
| 202 | |
| 203 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name)); |
| 204 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle)); |
| 205 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status)); |
| 206 | |
| 207 | // Find additional Participant |
| 208 | $this->openCiviPage("event/search", "reset=1"); |
| 209 | $this->type("sort_name", $participantfname); |
| 210 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 211 | $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE); |
| 212 | |
| 213 | $name = $participantfname . " " . $participantlname; |
| 214 | $status = 'Registered'; |
| 215 | |
| 216 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name)); |
| 217 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle)); |
| 218 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status)); |
| 219 | |
| 220 | // Edit page and remove some profile |
| 221 | $this->_testRemoveProfile($eventPageId); |
| 222 | |
| 223 | // logout |
| 224 | $this->webtestLogout(); |
| 225 | |
| 226 | $this->_testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4); |
| 227 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 228 | |
| 229 | // Log in using webtestLogin() method |
| 230 | $this->webtestLogin(); |
| 231 | |
| 232 | // Find Main Participant |
| 233 | $this->openCiviPage('event/search', "reset=1"); |
| 234 | $this->type("sort_name", $firstName2); |
| 235 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 236 | $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE); |
| 237 | |
| 238 | $name = $firstName2 . " " . $lastName2; |
| 239 | $status = 'Registered'; |
| 240 | |
| 241 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name)); |
| 242 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle)); |
| 243 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status)); |
| 244 | |
| 245 | // Find additional Participant |
| 246 | $this->openCiviPage("event/search", "reset=1"); |
| 247 | $this->type("sort_name", $participantfname2); |
| 248 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 249 | $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE); |
| 250 | |
| 251 | $name = $participantfname2 . " " . $participantlname2; |
| 252 | $status = 'Registered'; |
| 253 | |
| 254 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name)); |
| 255 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle)); |
| 256 | $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status)); |
| 257 | |
| 258 | // delete all custom data |
| 259 | if (isset($cfId)) { |
| 260 | $this->_removeEmailField($cfId); |
| 261 | } |
| 262 | foreach ($customId as $cid) { |
| 263 | $this->openCiviPage("admin/custom/group/field", "action=delete&reset=1&gid={$customGrpId1}&id=$cid"); |
| 264 | $this->click("_qf_DeleteField_next-bottom"); |
| 265 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 266 | } |
| 267 | $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=$customGrpId1"); |
| 268 | $this->click("_qf_DeleteGroup_next-bottom"); |
| 269 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * @param $customGrpId1 |
| 274 | * |
| 275 | * @return array |
| 276 | */ |
| 277 | public function _testGetCustomFieldId($customGrpId1) { |
| 278 | $customId = array(); |
| 279 | |
| 280 | // Create a custom data to add in profile |
| 281 | |
| 282 | $field1 = "Fname" . substr(sha1(rand()), 0, 7); |
| 283 | $field2 = "Mname" . substr(sha1(rand()), 0, 7); |
| 284 | $field3 = "Lname" . substr(sha1(rand()), 0, 7); |
| 285 | |
| 286 | // add custom fields for group 1 |
| 287 | $this->openCiviPage("admin/custom/group/field/add", "reset=1&action=add&gid=$customGrpId1"); |
| 288 | $this->type("label", $field1); |
| 289 | $this->check("is_searchable"); |
| 290 | $this->click("_qf_Field_next_new-bottom"); |
| 291 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 292 | |
| 293 | $this->type("label", $field2); |
| 294 | $this->check("is_searchable"); |
| 295 | $this->click("_qf_Field_next_new-bottom"); |
| 296 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 297 | |
| 298 | $this->type("label", $field3); |
| 299 | $this->check("is_searchable"); |
| 300 | $this->click("_qf_Field_done-bottom"); |
| 301 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 302 | |
| 303 | // get id of custom fields |
| 304 | $this->openCiviPage("admin/custom/group/field", "reset=1&action=browse&gid=$customGrpId1"); |
| 305 | $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href")); |
| 306 | $custom1 = $custom1[1]; |
| 307 | array_push($customId, $custom1); |
| 308 | $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href")); |
| 309 | $custom2 = $custom2[1]; |
| 310 | array_push($customId, $custom2); |
| 311 | $custom3 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[3]/td[8]/span/a[text()='Edit Field']/@href")); |
| 312 | $custom3 = $custom3[1]; |
| 313 | array_push($customId, $custom3); |
| 314 | |
| 315 | return $customId; |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * @param int $eventPageId |
| 320 | */ |
| 321 | public function _testRemoveProfile($eventPageId) { |
| 322 | $this->openCiviPage("event/manage/settings", "reset=1&action=update&id=$eventPageId"); |
| 323 | |
| 324 | // Go to Online Contribution tab |
| 325 | $this->click("link=Online Registration"); |
| 326 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
| 327 | $this->click("xpath=//*[@id='additional_custom_post_id_multiple_1']/parent::td/span/a[text()='remove profile']"); |
| 328 | $this->click("xpath=//*[@id='additional_custom_post_id_multiple_2']/parent::td/span/a[text()='remove profile']"); |
| 329 | $this->click("xpath=//*[@id='additional_custom_post_id_multiple_3']/parent::td/span/a[text()='remove profile']"); |
| 330 | $this->click("xpath=//*[@id='additional_custom_post_id_multiple_4']/parent::td/span/a[text()='remove profile']"); |
| 331 | $this->click("_qf_Registration_upload-bottom"); |
| 332 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * @param int $customId |
| 337 | * |
| 338 | * @return array |
| 339 | */ |
| 340 | public function _testGetProfileId($customId) { |
| 341 | // create profiles |
| 342 | $profileId = array(); |
| 343 | $profilefield = array( |
| 344 | 'street_address' => 'street_address', |
| 345 | 'supplemental_address_1' => 'supplemental_address_1', |
| 346 | 'city' => 'city', |
| 347 | ); |
| 348 | $location = 1; |
| 349 | $type = "Contact"; |
| 350 | $profileId1 = $this->_testCreateProfile($profilefield, $location, $type); |
| 351 | array_push($profileId, $profileId1); |
| 352 | |
| 353 | $profilefield = array( |
| 354 | 'street_address' => 'street_address', |
| 355 | 'city' => 'city', |
| 356 | 'phone' => 'phone', |
| 357 | 'postal_code' => 'postal_code', |
| 358 | ); |
| 359 | $location = 0; |
| 360 | $type = "Contact"; |
| 361 | $profileId2 = $this->_testCreateProfile($profilefield, $location, $type); |
| 362 | array_push($profileId, $profileId2); |
| 363 | |
| 364 | $profilefield = array( |
| 365 | 'nick_name' => 'nick_name', |
| 366 | 'url' => 'url', |
| 367 | ); |
| 368 | $location = 0; |
| 369 | $type = "Contact"; |
| 370 | $profileId3 = $this->_testCreateProfile($profilefield, $location, $type); |
| 371 | array_push($profileId, $profileId3); |
| 372 | |
| 373 | $profilefield = array( |
| 374 | 'current_employer' => 'current_employer', |
| 375 | 'job_title' => 'job_title', |
| 376 | ); |
| 377 | $location = 0; |
| 378 | $type = "Individual"; |
| 379 | $profileId4 = $this->_testCreateProfile($profilefield, $location, $type); |
| 380 | array_push($profileId, $profileId4); |
| 381 | |
| 382 | $profilefield = array( |
| 383 | 'middle_name' => 'middle_name', |
| 384 | 'gender_id' => 'gender_id', |
| 385 | ); |
| 386 | $location = 0; |
| 387 | $type = "Individual"; |
| 388 | $profileId5 = $this->_testCreateProfile($profilefield, $location, $type); |
| 389 | array_push($profileId, $profileId5); |
| 390 | |
| 391 | $profilefield = array( |
| 392 | 'custom_' . $customId[0] => 'custom_' . $customId[0], |
| 393 | 'custom_' . $customId[1] => 'custom_' . $customId[1], |
| 394 | 'custom_' . $customId[2] => 'custom_' . $customId[2], |
| 395 | ); |
| 396 | $location = 0; |
| 397 | $type = "Contact"; |
| 398 | $profileId6 = $this->_testCreateProfile($profilefield, $location, $type); |
| 399 | array_push($profileId, $profileId6); |
| 400 | |
| 401 | $profilefield = array( |
| 402 | 'participant_role' => 'participant_role', |
| 403 | ); |
| 404 | $location = 0; |
| 405 | $type = "Participant"; |
| 406 | $profileId7 = $this->_testCreateProfile($profilefield, $location, $type); |
| 407 | array_push($profileId, $profileId7); |
| 408 | |
| 409 | return $profileId; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * @param $profilefield |
| 414 | * @param int $location |
| 415 | * @param $type |
| 416 | * |
| 417 | * @return null |
| 418 | */ |
| 419 | public function _testCreateProfile($profilefield, $location = 0, $type) { |
| 420 | $locationfields = array( |
| 421 | 'supplemental_address_1', |
| 422 | 'supplemental_address_2', |
| 423 | 'city', |
| 424 | 'country', |
| 425 | 'email', |
| 426 | 'state', |
| 427 | 'street_address', |
| 428 | 'postal_code', |
| 429 | ); |
| 430 | |
| 431 | // Add new profile. |
| 432 | $profilename = "Profile_" . substr(sha1(rand()), 0, 7); |
| 433 | $this->openCiviPage("admin/uf/group", "reset=1"); |
| 434 | $this->click('newCiviCRMProfile-top'); |
| 435 | $this->waitForElementPresent('_qf_Group_next-top'); |
| 436 | |
| 437 | //Name of profile |
| 438 | $this->type('title', $profilename); |
| 439 | $this->click('uf_group_type_Profile'); |
| 440 | $this->click('_qf_Group_next-top'); |
| 441 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 442 | $profileId = $this->urlArg('gid'); |
| 443 | |
| 444 | //Add field to profile_testCreateProfile |
| 445 | foreach ($profilefield as $key => $value) { |
| 446 | $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId"); |
| 447 | if (in_array($value, $locationfields)) { |
| 448 | $this->select("field_name[0]", "value={$type}"); |
| 449 | $this->select("field_name[1]", "value={$value}"); |
| 450 | $this->select("field_name[2]", "value={$location}"); |
| 451 | $this->type("label", $value); |
| 452 | } |
| 453 | else { |
| 454 | $this->select("field_name[0]", "value={$type}"); |
| 455 | $this->select("field_name[1]", "value={$value}"); |
| 456 | $this->type("label", $value); |
| 457 | } |
| 458 | $this->click('_qf_Field_next-top'); |
| 459 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 460 | } |
| 461 | return $profileId; |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * @param $eventTitle |
| 466 | * @param $eventDescription |
| 467 | */ |
| 468 | public function _testAddEventInfo($eventTitle, $eventDescription) { |
| 469 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
| 470 | |
| 471 | $this->select("event_type_id", "value=1"); |
| 472 | |
| 473 | // Attendee role s/b selected now. |
| 474 | $this->select("default_role_id", "value=1"); |
| 475 | |
| 476 | // Enter Event Title, Summary and Description |
| 477 | $this->type("title", $eventTitle); |
| 478 | $this->type("summary", "This is a great conference. Sign up now!"); |
| 479 | |
| 480 | // Type description in ckEditor (fieldname, text to type, editor) |
| 481 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); |
| 482 | |
| 483 | // Choose Start and End dates. |
| 484 | // Using helper webtestFillDate function. |
| 485 | $this->webtestFillDateTime("start_date", "+1 week"); |
| 486 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); |
| 487 | |
| 488 | $this->type("max_participants", "50"); |
| 489 | $this->click("is_map"); |
| 490 | $this->click("_qf_EventInfo_upload-bottom"); |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * @param $streetAddress |
| 495 | */ |
| 496 | public function _testAddLocation($streetAddress) { |
| 497 | // Wait for Location tab form to load |
| 498 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 499 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
| 500 | |
| 501 | // Fill in address fields |
| 502 | //$streetAddress = "100 Main Street"; |
| 503 | $this->type("address_1_street_address", $streetAddress); |
| 504 | $this->type("address_1_city", "San Francisco"); |
| 505 | $this->waitForElementPresent('address_1_country_id'); |
| 506 | $this->select("address_1_country_id", "value=1228"); |
| 507 | $this->type("address_1_postal_code", "94117"); |
| 508 | $this->select("address_1_state_province_id", "value=1004"); |
| 509 | $this->type("email_1_email", "info@civicrm.org"); |
| 510 | |
| 511 | $this->click("_qf_Location_upload-bottom"); |
| 512 | |
| 513 | // Wait for "saved" status msg |
| 514 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
| 515 | $this->waitForText('crm-notification-container', "'Event Location' information has been saved."); |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * @param bool $discount |
| 520 | * @param bool $priceSet |
| 521 | * @param string $processorName |
| 522 | */ |
| 523 | public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") { |
| 524 | // Go to Fees tab |
| 525 | $this->click("link=Fees"); |
| 526 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); |
| 527 | $this->click("CIVICRM_QFID_1_is_monetary"); |
| 528 | |
| 529 | // select newly created processor |
| 530 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; |
| 531 | $this->assertElementContainsText('css=.crm-event-manage-fee-form-block-payment_processor', $processorName); |
| 532 | $this->check($xpath); |
| 533 | $this->select("financial_type_id", "label=Event Fee"); |
| 534 | if ($priceSet) { |
| 535 | // get one - TBD |
| 536 | } |
| 537 | else { |
| 538 | $this->type("label_1", "Member"); |
| 539 | $this->type("value_1", "250.00"); |
| 540 | $this->type("label_2", "Non-member"); |
| 541 | $this->type("value_2", "325.00"); |
| 542 | //set default |
| 543 | $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input"); |
| 544 | } |
| 545 | |
| 546 | if ($discount) { |
| 547 | // enter early bird discounts TBD |
| 548 | } |
| 549 | |
| 550 | $this->click("_qf_Fee_upload-bottom"); |
| 551 | |
| 552 | // Wait for "saved" status msg |
| 553 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); |
| 554 | $this->waitForTextPresent("'Fees' information has been saved."); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * @param int $profileId |
| 559 | * |
| 560 | * @return null |
| 561 | */ |
| 562 | public function _testAddMultipleProfile($profileId) { |
| 563 | // Go to Online Contribution tab |
| 564 | $this->click("link=Online Registration"); |
| 565 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
| 566 | $this->click("is_online_registration"); |
| 567 | $this->check("is_multiple_registrations"); |
| 568 | $this->select("xpath=//*[@id='custom_pre_id']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=1"); |
| 569 | $this->select("xpath=//*[@id='custom_post_id']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[3]); |
| 570 | $this->select("xpath=//*[@id='additional_custom_post_id']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "- same as for main contact -"); |
| 571 | |
| 572 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 573 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 574 | $this->waitForElementPresent("custom_post_id_multiple_1"); |
| 575 | $this->select("xpath=//*[@id='custom_post_id_multiple_1']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[2]); |
| 576 | |
| 577 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 578 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 579 | $this->waitForElementPresent("custom_post_id_multiple_2"); |
| 580 | $this->select("xpath=//*[@id='custom_post_id_multiple_2']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[1]); |
| 581 | |
| 582 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 583 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 584 | $this->waitForElementPresent("custom_post_id_multiple_3"); |
| 585 | $this->select("xpath=//*[@id='custom_post_id_multiple_3']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[4]); |
| 586 | |
| 587 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 588 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 589 | $this->waitForElementPresent("custom_post_id_multiple_4"); |
| 590 | $this->select("xpath=//*[@id='custom_post_id_multiple_4']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[5]); |
| 591 | |
| 592 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 593 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 594 | $this->waitForElementPresent("custom_post_id_multiple_5"); |
| 595 | $this->select("xpath=//*[@id='custom_post_id_multiple_5']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[6]); |
| 596 | |
| 597 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 598 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 599 | $this->waitForElementPresent("additional_custom_post_id_multiple_1"); |
| 600 | $this->select("xpath=//*[@id='additional_custom_post_id_multiple_1']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[5]); |
| 601 | |
| 602 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 603 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 604 | $this->waitForElementPresent("additional_custom_post_id_multiple_2"); |
| 605 | $this->select("xpath=//*[@id='additional_custom_post_id_multiple_2']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[1]); |
| 606 | |
| 607 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 608 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 609 | $this->waitForElementPresent("additional_custom_post_id_multiple_3"); |
| 610 | $this->select("xpath=//*[@id='additional_custom_post_id_multiple_3']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[2]); |
| 611 | |
| 612 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 613 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']"); |
| 614 | $this->waitForElementPresent("additional_custom_post_id_multiple_4"); |
| 615 | $this->select("xpath=//*[@id='additional_custom_post_id_multiple_4']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[3]); |
| 616 | |
| 617 | $this->click("CIVICRM_QFID_1_is_email_confirm"); |
| 618 | $this->type("confirm_from_name", "TestEvent"); |
| 619 | $this->type("confirm_from_email", "testevent@test.com"); |
| 620 | $this->click("_qf_Registration_upload-bottom"); |
| 621 | |
| 622 | // Wait for "saved" status msg |
| 623 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
| 624 | $this->waitForText('crm-notification-container', "'Online Registration' information has been saved."); |
| 625 | |
| 626 | return $this->urlArg('id'); |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * @param int $eventPageId |
| 631 | * @param int $customId |
| 632 | * @param string $firstName |
| 633 | * @param string $lastName |
| 634 | * @param string $participantfname |
| 635 | * @param string $participantlname |
| 636 | * @param $email1 |
| 637 | * @param $email2 |
| 638 | */ |
| 639 | function _testEventRegistration($eventPageId, $customId, $firstName, $lastName, |
| 640 | $participantfname, $participantlname, $email1, $email2 |
| 641 | ) { |
| 642 | $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom"); |
| 643 | $this->select("additional_participants", "value=1"); |
| 644 | |
| 645 | $this->type("email-Primary", $email1); |
| 646 | $this->type("first_name", $firstName); |
| 647 | $this->type("last_name", $lastName); |
| 648 | $this->type("street_address-1", "Test street addres"); |
| 649 | $this->type("city-1", "Mumbai"); |
| 650 | $this->type("postal_code-1", "2354"); |
| 651 | $this->select("state_province-1", "value=1001"); |
| 652 | |
| 653 | // Credit Card Info |
| 654 | $this->select("credit_card_type", "value=Visa"); |
| 655 | $this->type("credit_card_number", "4111111111111111"); |
| 656 | $this->type("cvv2", "000"); |
| 657 | $this->select("credit_card_exp_date[M]", "value=1"); |
| 658 | $this->select("credit_card_exp_date[Y]", "value=2020"); |
| 659 | |
| 660 | //Billing Info |
| 661 | $this->type("billing_first_name", $firstName . 'billing'); |
| 662 | $this->type("billing_last_name", $lastName . 'billing'); |
| 663 | $this->type("billing_street_address-5", "0121 Mount Highschool."); |
| 664 | $this->type(" billing_city-5", "Shangai"); |
| 665 | $this->select("billing_country_id-5", "value=1228"); |
| 666 | $this->select("billing_state_province_id-5", "value=1004"); |
| 667 | $this->type("billing_postal_code-5", "94129"); |
| 668 | |
| 669 | $this->type("current_employer", "ABCD"); |
| 670 | $this->type("job_title", "Painter"); |
| 671 | $this->waitForElementPresent('nick_name'); |
| 672 | $this->type("nick_name", "Nick"); |
| 673 | $this->type("url-1", "http://www.test.com"); |
| 674 | |
| 675 | $this->waitForElementPresent('street_address-Primary'); |
| 676 | $this->type("street_address-Primary", "Primary street address"); |
| 677 | $this->type("city-Primary", "primecity"); |
| 678 | $this->type("phone-Primary-1", "98667764"); |
| 679 | $this->type("postal_code-Primary", "6548"); |
| 680 | |
| 681 | $this->type("custom_" . $customId[0], "fname_custom1"); |
| 682 | $this->type("custom_" . $customId[1], "mname_custom1"); |
| 683 | $this->type("custom_" . $customId[2], "lname_custom1"); |
| 684 | |
| 685 | $this->type("middle_name", "xyz"); |
| 686 | $this->click("name=gender_id value=2"); |
| 687 | $this->waitForElementPresent('participant_role'); |
| 688 | $this->select("participant_role", "value=2"); |
| 689 | |
| 690 | $this->click("_qf_Register_upload-bottom"); |
| 691 | $this->waitForElementPresent("_qf_Participant_1_next-Array"); |
| 692 | |
| 693 | $this->type("email-Primary", $email2); |
| 694 | $this->type("first_name", $participantfname); |
| 695 | $this->type("last_name", $participantlname); |
| 696 | $this->type("street_address-1", "participant street addres"); |
| 697 | $this->type("city-1", "pune"); |
| 698 | $this->type("postal_code-1", "2354"); |
| 699 | $this->select("state_province-1", "value=1001"); |
| 700 | |
| 701 | $this->type("current_employer", "ABCD"); |
| 702 | $this->type("job_title", "Potato picker"); |
| 703 | |
| 704 | $this->type("custom_" . $customId[0], "participant_custom1"); |
| 705 | $this->type("custom_" . $customId[1], "participant_custom1"); |
| 706 | $this->type("custom_" . $customId[2], "participant_custom1"); |
| 707 | |
| 708 | $this->waitForElementPresent('street_address-Primary'); |
| 709 | $this->type("street_address-Primary", "Primary street address"); |
| 710 | $this->type("city-Primary", "primecity"); |
| 711 | $this->type("phone-Primary-1", "98667764"); |
| 712 | $this->type("postal_code-Primary", "6548"); |
| 713 | |
| 714 | $this->type("nick_name", "Nick1"); |
| 715 | $this->type("url-1", "http://www.part.com"); |
| 716 | |
| 717 | $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom"); |
| 718 | $this->click("_qf_Confirm_next-bottom"); |
| 719 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * @param int $eventPageId |
| 724 | * @param int $customId |
| 725 | * @param string $firstName2 |
| 726 | * @param string $lastName2 |
| 727 | * @param string $participantfname2 |
| 728 | * @param $participantlname2 |
| 729 | * @param $email3 |
| 730 | * @param $email4 |
| 731 | */ |
| 732 | public function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) { |
| 733 | $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom"); |
| 734 | $this->select("additional_participants", "value=1"); |
| 735 | |
| 736 | $this->type("email-Primary", $email4); |
| 737 | $this->type("first_name", $firstName2); |
| 738 | $this->type("last_name", $lastName2); |
| 739 | $this->type("street_address-1", "Test street addres"); |
| 740 | $this->type("city-1", "Mumbai"); |
| 741 | $this->type("postal_code-1", "2354"); |
| 742 | $this->select("state_province-1", "value=1001"); |
| 743 | |
| 744 | // Credit Card Info |
| 745 | $this->select("credit_card_type", "value=Visa"); |
| 746 | $this->type("credit_card_number", "4111111111111111"); |
| 747 | $this->type("cvv2", "000"); |
| 748 | $this->select("credit_card_exp_date[M]", "value=1"); |
| 749 | $this->select("credit_card_exp_date[Y]", "value=2020"); |
| 750 | |
| 751 | //Billing Info |
| 752 | $this->type("billing_first_name", $firstName2 . 'billing'); |
| 753 | $this->type("billing_last_name", $lastName2 . 'billing'); |
| 754 | $this->type("billing_street_address-5", "0121 Mount Highschool."); |
| 755 | $this->type(" billing_city-5", "Shangai"); |
| 756 | $this->select("billing_country_id-5", "value=1228"); |
| 757 | $this->select("billing_state_province_id-5", "value=1004"); |
| 758 | $this->type("billing_postal_code-5", "94129"); |
| 759 | |
| 760 | $this->type("current_employer", "ABCD"); |
| 761 | $this->type("job_title", "Painter"); |
| 762 | |
| 763 | $this->type("nick_name", "Nickkk"); |
| 764 | $this->type("url-1", "http://www.testweb.com"); |
| 765 | |
| 766 | $this->type("street_address-Primary", "Primary street address"); |
| 767 | $this->type("city-Primary", "primecity"); |
| 768 | $this->type("phone-Primary-1", "9866776422"); |
| 769 | $this->type("postal_code-Primary", "6534"); |
| 770 | |
| 771 | $this->type("custom_" . $customId[0], "fname_custom1"); |
| 772 | $this->type("custom_" . $customId[1], "mname_custom1"); |
| 773 | $this->type("custom_" . $customId[2], "lname_custom1"); |
| 774 | |
| 775 | $this->type("middle_name", "xyz"); |
| 776 | $this->click("name=gender_id value=2"); |
| 777 | $this->select("participant_role", "value=2"); |
| 778 | |
| 779 | $this->click("_qf_Register_upload-bottom"); |
| 780 | $this->waitForElementPresent("_qf_Participant_1_next-Array"); |
| 781 | |
| 782 | $this->type("email-Primary", $email3); |
| 783 | $this->type("first_name", $participantfname2); |
| 784 | $this->type("last_name", $participantlname2); |
| 785 | $this->type("street_address-1", "participant street addres"); |
| 786 | $this->type("city-1", "pune"); |
| 787 | $this->type("postal_code-1", "2354"); |
| 788 | $this->select("state_province-1", "value=1001"); |
| 789 | |
| 790 | $this->type("current_employer", "ABCD"); |
| 791 | $this->type("job_title", "BATCHER"); |
| 792 | |
| 793 | $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom"); |
| 794 | $this->click("_qf_Confirm_next-bottom"); |
| 795 | } |
| 796 | |
| 797 | /** |
| 798 | * @return array|string |
| 799 | */ |
| 800 | public function _addEmailField() { |
| 801 | //add email field in name and address profile |
| 802 | $this->openCiviPage('admin/uf/group/field/add', 'reset=1&action=add&gid=1', "_qf_Field_next-bottom"); |
| 803 | $this->select("field_name[0]", "value=Contact"); |
| 804 | $this->select("field_name[1]", "value=email"); |
| 805 | $this->select("field_name[2]", "value=0"); |
| 806 | $this->click('_qf_Field_next-bottom'); |
| 807 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 808 | |
| 809 | $cfId = ""; |
| 810 | //check wheather webtest has created the field |
| 811 | if ($this->assertElementNotContainsText('crm-notification-container', "The selected field was not added. It already exists in this profile")) { |
| 812 | $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']"); |
| 813 | $cfId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']/@href")); |
| 814 | $cfId = $cfId[1]; |
| 815 | } |
| 816 | return $cfId; |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * @param int $cfId |
| 821 | */ |
| 822 | public function _removeEmailField($cfId) { |
| 823 | $this->openCiviPage("admin/uf/group/field", "action=delete&id={$cfId}"); |
| 824 | $this->click("_qf_Field_next-bottom"); |
| 825 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 826 | } |
| 827 | } |