| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.6 | |
| 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_Contact_AddTest |
| 31 | */ |
| 32 | class WebTest_Contact_AddTest extends CiviSeleniumTestCase { |
| 33 | |
| 34 | protected function setUp() { |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function testIndividualAdd() { |
| 39 | $this->webtestLogin(); |
| 40 | |
| 41 | $groupName = $this->WebtestAddGroup(); |
| 42 | |
| 43 | // go to display preferences to enable Open ID field |
| 44 | $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom"); |
| 45 | $this->check("xpath=//ul[@id='contactEditBlocks']//li/span[2]/label[text()='Open ID']/../input"); |
| 46 | $this->click("_qf_Display_next-bottom"); |
| 47 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 48 | $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); |
| 49 | |
| 50 | //contact details section |
| 51 | //select prefix |
| 52 | $this->click("prefix_id"); |
| 53 | $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix')); |
| 54 | |
| 55 | //fill in first name |
| 56 | $this->type("first_name", substr(sha1(rand()), 0, 7) . "John"); |
| 57 | |
| 58 | //fill in middle name |
| 59 | $this->type("middle_name", "Bruce"); |
| 60 | |
| 61 | //fill in last name |
| 62 | $this->type("last_name", substr(sha1(rand()), 0, 7) . "Smith"); |
| 63 | |
| 64 | //select suffix |
| 65 | $this->select("suffix_id", "value=3"); |
| 66 | |
| 67 | //fill in nick name |
| 68 | $this->type("nick_name", "jsmith"); |
| 69 | |
| 70 | //fill in email |
| 71 | $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com"); |
| 72 | |
| 73 | //fill in phone |
| 74 | $this->type("phone_1_phone", "2222-4444"); |
| 75 | |
| 76 | //fill in IM |
| 77 | $this->type("im_1_name", "testYahoo"); |
| 78 | |
| 79 | //fill in openID |
| 80 | $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "openid.com"); |
| 81 | |
| 82 | //fill in website |
| 83 | $this->type("website_1_url", "http://www.john.com"); |
| 84 | |
| 85 | //fill in source |
| 86 | $this->type("contact_source", "johnSource"); |
| 87 | |
| 88 | //fill in external identifier |
| 89 | $indExternalId = substr(sha1(rand()), 0, 4); |
| 90 | $this->type("external_identifier", $indExternalId); |
| 91 | |
| 92 | //check for matching contact |
| 93 | $this->click("_qf_Contact_refresh_dedupe"); |
| 94 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 95 | |
| 96 | //address section |
| 97 | $this->click("addressBlock"); |
| 98 | $this->waitForElementPresent("address_1_street_address"); |
| 99 | //fill in address 1 |
| 100 | $this->type("address_1_street_address", "902C El Camino Way SW"); |
| 101 | $this->type("address_1_city", "Dumfries"); |
| 102 | $this->type("address_1_postal_code", "1234"); |
| 103 | |
| 104 | $this->click("address_1_country_id"); |
| 105 | $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID()); |
| 106 | |
| 107 | if ($this->assertElementContainsText('address_table_1', "Latitude")) { |
| 108 | $this->type("address_1_geo_code_1", "1234"); |
| 109 | $this->type("address_1_geo_code_2", "5678"); |
| 110 | } |
| 111 | |
| 112 | //fill in address 2 |
| 113 | $this->click("//div[@id='addMoreAddress1']/a/span"); |
| 114 | $this->waitForElementPresent("address_2_street_address"); |
| 115 | $this->type("address_2_street_address", "2782Y Dowlen Path W"); |
| 116 | $this->type("address_2_city", "Birmingham"); |
| 117 | $this->type("address_2_postal_code", "3456"); |
| 118 | |
| 119 | $this->click("address_2_country_id"); |
| 120 | $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID()); |
| 121 | |
| 122 | if ($this->assertElementContainsText('address_table_2', "Latitude")) { |
| 123 | $this->type("address_2_geo_code_1", "1234"); |
| 124 | $this->type("address_2_geo_code_2", "5678"); |
| 125 | } |
| 126 | |
| 127 | //Communication Preferences section |
| 128 | $this->click("commPrefs"); |
| 129 | |
| 130 | //select greeting/addressee options |
| 131 | $this->waitForElementPresent("email_greeting_id"); |
| 132 | $this->select("email_greeting_id", "value=2"); |
| 133 | $this->select("postal_greeting_id", "value=3"); |
| 134 | |
| 135 | //Select preferred method for Privacy |
| 136 | $this->click("privacy[do_not_trade]"); |
| 137 | $this->click("privacy[do_not_sms]"); |
| 138 | |
| 139 | //Select preferred method(s) of communication |
| 140 | $this->click("preferred_communication_method[1]"); |
| 141 | $this->click("preferred_communication_method[2]"); |
| 142 | |
| 143 | //select preferred language |
| 144 | $this->waitForElementPresent("preferred_language"); |
| 145 | $this->select("preferred_language", "value=en_US"); |
| 146 | |
| 147 | //Notes section |
| 148 | $this->click("notesBlock"); |
| 149 | $this->waitForElementPresent("subject"); |
| 150 | $this->type("subject", "test note"); |
| 151 | $this->type("note", "this is a test note contact webtest"); |
| 152 | $this->assertElementContainsText('notesBlock', "Subject\n Note"); |
| 153 | |
| 154 | //Demographics section |
| 155 | $this->click("//div[@class='crm-accordion-header' and contains(.,'Demographics')]"); |
| 156 | $this->waitForElementPresent("birth_date"); |
| 157 | |
| 158 | $this->webtestFillDate('birth_date', "-1 year"); |
| 159 | |
| 160 | //Tags and Groups section |
| 161 | $this->click("tagGroup"); |
| 162 | |
| 163 | // select group |
| 164 | $this->select("group", "label=$groupName"); |
| 165 | $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]"); |
| 166 | |
| 167 | // Clicking save. |
| 168 | $this->click("_qf_Contact_upload_view"); |
| 169 | |
| 170 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 171 | $this->waitForText('crm-notification-container', "Contact Saved"); |
| 172 | } |
| 173 | |
| 174 | public function testHouseholdAdd() { |
| 175 | $this->webtestLogin(); |
| 176 | |
| 177 | $groupName = $this->WebtestAddGroup(); |
| 178 | |
| 179 | // go to display preferences to enable Open ID field |
| 180 | $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom"); |
| 181 | $this->check("xpath=//ul[@id='contactEditBlocks']//li/span[2]/label[text()='Open ID']/../input"); |
| 182 | $this->click("_qf_Display_next-bottom"); |
| 183 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 184 | |
| 185 | $this->openCiviPage('contact/add', "reset=1&ct=Household"); |
| 186 | |
| 187 | //contact details section |
| 188 | //fill in Household name |
| 189 | $this->click("household_name"); |
| 190 | $name = substr(sha1(rand()), 0, 7) . "Fraddie Grant's home "; |
| 191 | $this->type("household_name", $name); |
| 192 | |
| 193 | //fill in nick name |
| 194 | $this->type("nick_name", substr(sha1(rand()), 0, 7) . "Grant's home"); |
| 195 | |
| 196 | //fill in email |
| 197 | $email = substr(sha1(rand()), 0, 7) . "fraddiegrantshome@web.com "; |
| 198 | $this->type("email_1_email", $email); |
| 199 | $this->click("Email_1_IsBulkmail"); |
| 200 | |
| 201 | //fill in phone |
| 202 | $this->type("phone_1_phone", "444-4444"); |
| 203 | $this->select("phone_1_phone_type_id", "value=" . $this->webtestGetFirstValueForOptionGroup('phone_type')); |
| 204 | |
| 205 | //fill in IM |
| 206 | foreach (array('Yahoo', 'MSN', 'AIM', 'GTalk', 'Jabber', 'Skype') as $option) { |
| 207 | $this->assertSelectHasOption('im_1_provider_id', $option); |
| 208 | } |
| 209 | $this->type("im_1_name", "testSkype"); |
| 210 | $this->select("im_1_location_type_id", "value=3"); |
| 211 | $this->select("im_1_provider_id", "value=6"); |
| 212 | |
| 213 | //fill in openID |
| 214 | $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "shomeopenid.com"); |
| 215 | |
| 216 | //fill in website url |
| 217 | $this->type("website_1_url", "http://www.fraddiegrantshome.com"); |
| 218 | |
| 219 | //fill in contact source |
| 220 | $this->type("contact_source", "Grant's home source"); |
| 221 | |
| 222 | //fill in external identifier |
| 223 | $houExternalId = substr(sha1(rand()), 0, 4); |
| 224 | $this->type("external_identifier", $houExternalId); |
| 225 | |
| 226 | //check for duplicate contact |
| 227 | $this->click("_qf_Contact_refresh_dedupe"); |
| 228 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 229 | |
| 230 | //address section |
| 231 | $this->click("addressBlock"); |
| 232 | $this->waitForElementPresent("address_1_street_address"); |
| 233 | $this->type("address_1_street_address", "938U Bay Rd E"); |
| 234 | $this->type("address_1_city", "Birmingham"); |
| 235 | $this->type("address_1_postal_code", "35278"); |
| 236 | |
| 237 | $this->click("address_1_country_id"); |
| 238 | $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID()); |
| 239 | |
| 240 | if ($this->assertElementContainsText('address_table_1', "Latitude")) { |
| 241 | $this->type("address_1_geo_code_1", "1234"); |
| 242 | $this->type("address_1_geo_code_2", "5678"); |
| 243 | } |
| 244 | |
| 245 | //Communication Preferences section |
| 246 | $this->click("commPrefs"); |
| 247 | |
| 248 | //select greeting/addressee options |
| 249 | $this->waitForElementPresent("addressee_id"); |
| 250 | $this->select("addressee_id", "value=4"); |
| 251 | $this->type("addressee_custom", "Grant's home"); |
| 252 | |
| 253 | //Select preferred method(s) of communication |
| 254 | $this->click("preferred_communication_method[1]"); |
| 255 | $this->click("preferred_communication_method[2]"); |
| 256 | $this->click("preferred_communication_method[5]"); |
| 257 | |
| 258 | //Select preferred method for Privacy |
| 259 | $this->click("privacy[do_not_sms]"); |
| 260 | |
| 261 | //select preferred language |
| 262 | $this->waitForElementPresent("preferred_language"); |
| 263 | $this->select("preferred_language", "value=fr_FR"); |
| 264 | |
| 265 | //Notes section |
| 266 | $this->clickAt("//*[@id='Contact']/div[2]/div[6]/div[1]"); |
| 267 | $this->waitForElementPresent("subject"); |
| 268 | $this->type("subject", "Grant's note"); |
| 269 | $this->type("note", "This is a household contact webtest note."); |
| 270 | |
| 271 | // select group |
| 272 | $this->clickAt("xpath=//div[text()='Tags and Groups']"); |
| 273 | $this->select("group", "label=$groupName"); |
| 274 | |
| 275 | //tags section |
| 276 | $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]"); |
| 277 | |
| 278 | // Clicking save. |
| 279 | $this->click("_qf_Contact_upload_view"); |
| 280 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 281 | |
| 282 | $this->waitForText('crm-notification-container', "Contact Saved"); |
| 283 | } |
| 284 | |
| 285 | public function testOrganizationAdd() { |
| 286 | $this->webtestLogin(); |
| 287 | |
| 288 | $groupName = $this->WebtestAddGroup(); |
| 289 | |
| 290 | // go to display preferences to enable Open ID field |
| 291 | $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom"); |
| 292 | $this->check("xpath=//ul[@id='contactEditBlocks']//li/span[2]/label[text()='Open ID']/../input"); |
| 293 | $this->click("_qf_Display_next-bottom"); |
| 294 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 295 | |
| 296 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization'); |
| 297 | |
| 298 | //contact details section |
| 299 | //fill in Organization name |
| 300 | $this->click("organization_name"); |
| 301 | $this->type("organization_name", substr(sha1(rand()), 0, 7) . "syntel tech"); |
| 302 | |
| 303 | //fill in legal name |
| 304 | $this->type("legal_name", "syntel tech Ltd"); |
| 305 | |
| 306 | //fill in nick name |
| 307 | $this->type("nick_name", "syntel"); |
| 308 | |
| 309 | //fill in email |
| 310 | $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "info@syntel.com"); |
| 311 | |
| 312 | //fill in phone |
| 313 | $this->type("phone_1_phone", "222-7777"); |
| 314 | $this->select("phone_1_phone_type_id", "value=2"); |
| 315 | |
| 316 | //fill in IM |
| 317 | $this->type("im_1_name", "testGtalk"); |
| 318 | $this->select("im_1_location_type_id", "value=4"); |
| 319 | $this->select("im_1_provider_id", "value=4"); |
| 320 | |
| 321 | //fill in openID |
| 322 | $this->select("openid_1_location_type_id", "value=5"); |
| 323 | $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "Openid.com"); |
| 324 | |
| 325 | //fill in website url |
| 326 | $this->type("website_1_url", "http://syntelglobal.com"); |
| 327 | |
| 328 | //fill in contact source |
| 329 | $this->type("contact_source", "syntel's source"); |
| 330 | |
| 331 | //fill in external identifier |
| 332 | $orgExternalId = substr(sha1(rand()), 0, 4); |
| 333 | $this->type("external_identifier", $orgExternalId); |
| 334 | |
| 335 | //check for duplicate contact |
| 336 | $this->click("_qf_Contact_refresh_dedupe"); |
| 337 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 338 | |
| 339 | //address section |
| 340 | $this->click("addressBlock"); |
| 341 | $this->waitForElementPresent("address_1_street_address"); |
| 342 | $this->type("address_1_street_address", "928A Lincoln Way W"); |
| 343 | $this->type("address_1_city", "Madison"); |
| 344 | $this->type("address_1_postal_code", "68748"); |
| 345 | |
| 346 | $this->click("address_1_country_id"); |
| 347 | $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID()); |
| 348 | |
| 349 | if ($this->assertElementContainsText('address_table_1', "Latitude")) { |
| 350 | $this->type("address_1_geo_code_1", "1234"); |
| 351 | $this->type("address_1_geo_code_2", "5678"); |
| 352 | } |
| 353 | |
| 354 | //Communication Preferences section |
| 355 | $this->click("commPrefs"); |
| 356 | |
| 357 | //Select preferred method(s) of communication |
| 358 | $this->click("preferred_communication_method[2]"); |
| 359 | $this->click("preferred_communication_method[5]"); |
| 360 | |
| 361 | //Select preferred method for Privacy |
| 362 | $this->click("privacy[do_not_sms]"); |
| 363 | $this->click("privacy[do_not_mail]"); |
| 364 | //select preferred language |
| 365 | $this->waitForElementPresent("preferred_language"); |
| 366 | $this->select("preferred_language", "value=de_DE"); |
| 367 | |
| 368 | //Notes section |
| 369 | $this->click("notesBlock"); |
| 370 | $this->waitForElementPresent("subject"); |
| 371 | $this->type("subject", "syntel global note"); |
| 372 | $this->type("note", "This is a note for syntel global's contact webtest."); |
| 373 | |
| 374 | //Tags and Groups section |
| 375 | $this->click("tagGroup"); |
| 376 | |
| 377 | // select group |
| 378 | $this->select("group", "label=$groupName"); |
| 379 | |
| 380 | $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]"); |
| 381 | |
| 382 | // Clicking save. |
| 383 | $this->click("_qf_Contact_upload_view"); |
| 384 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 385 | |
| 386 | $this->waitForText('crm-notification-container', "Contact Saved"); |
| 387 | } |
| 388 | |
| 389 | public function testIndividualAddWithSharedAddress() { |
| 390 | $this->webtestLogin(); |
| 391 | |
| 392 | $this->openCiviPage('contact/add', "reset=1&ct=Individual"); |
| 393 | |
| 394 | //contact details section |
| 395 | //select prefix |
| 396 | $this->click("prefix_id"); |
| 397 | $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix')); |
| 398 | |
| 399 | //fill in first name |
| 400 | $this->type("first_name", substr(sha1(rand()), 0, 7) . "John"); |
| 401 | |
| 402 | //fill in middle name |
| 403 | $this->type("middle_name", "Bruce"); |
| 404 | |
| 405 | $lastName = substr(sha1(rand()), 0, 7) . "Smith"; |
| 406 | //fill in last name |
| 407 | $this->type("last_name", $lastName); |
| 408 | |
| 409 | //create new current employer |
| 410 | $currentEmployer = substr(sha1(rand()), 0, 7) . "Web Access"; |
| 411 | |
| 412 | //fill in email |
| 413 | $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com"); |
| 414 | |
| 415 | //fill in phone |
| 416 | $this->type("phone_1_phone", "2222-4444"); |
| 417 | |
| 418 | //fill in source |
| 419 | $this->type("contact_source", "johnSource"); |
| 420 | |
| 421 | //address section |
| 422 | $this->click("addressBlock"); |
| 423 | $this->waitForElementPresent("address_1_street_address"); |
| 424 | |
| 425 | $this->select('address_1_location_type_id', 'value=2'); |
| 426 | |
| 427 | $this->click('address[1][use_shared_address]'); |
| 428 | |
| 429 | // create new organization with dialog |
| 430 | $this->clickAt("xpath=//div[@id='s2id_address_1_master_contact_id']/a"); |
| 431 | $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]"); |
| 432 | |
| 433 | // create new contact using dialog |
| 434 | $this->waitForElementPresent("css=div#crm-profile-block"); |
| 435 | $this->waitForElementPresent("_qf_Edit_next"); |
| 436 | |
| 437 | $this->type('organization_name', $currentEmployer); |
| 438 | $this->type('street_address-1', '902C El Camino Way SW'); |
| 439 | $this->type("email-Primary", "john@gmail.com" . substr(sha1(rand()), 0, 7)); |
| 440 | $this->type('city-1', 'Dumfries'); |
| 441 | $this->type('postal_code-1', '1234'); |
| 442 | $this->select('state_province-1', 'value=1001'); |
| 443 | |
| 444 | $this->click("_qf_Edit_next"); |
| 445 | |
| 446 | $this->select2('employer_id', $currentEmployer); |
| 447 | |
| 448 | //make sure shared address is selected |
| 449 | $this->waitForElementPresent('selected_shared_address-1'); |
| 450 | |
| 451 | //fill in address 2 |
| 452 | $this->click("//div[@id='addMoreAddress1']/a/span"); |
| 453 | $this->waitForElementPresent("address_2_street_address"); |
| 454 | |
| 455 | $this->select('address_2_location_type_id', 'value=1'); |
| 456 | |
| 457 | $this->click('address[2][use_shared_address]'); |
| 458 | |
| 459 | // create new household with dialog |
| 460 | $this->clickAt("xpath=//div[@id='s2id_address_2_master_contact_id']/a"); |
| 461 | $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Household')]"); |
| 462 | |
| 463 | // create new contact using dialog |
| 464 | $this->waitForElementPresent("css=div#crm-profile-block"); |
| 465 | $this->waitForElementPresent("_qf_Edit_next"); |
| 466 | |
| 467 | $sharedHousehold = substr(sha1(rand()), 0, 7) . 'Smith Household'; |
| 468 | $this->type('household_name', $sharedHousehold); |
| 469 | $this->type('street_address-1', '2782Y Dowlen Path W'); |
| 470 | $this->type("email-Primary", substr(sha1(rand()), 0, 7) . "john@gmail.com"); |
| 471 | $this->type('city-1', 'Birmingham'); |
| 472 | $this->type('postal_code-1', '3456'); |
| 473 | $this->select('state_province-1', 'value=1001'); |
| 474 | |
| 475 | $this->click("_qf_Edit_next"); |
| 476 | |
| 477 | //make sure shared address is selected |
| 478 | $this->waitForElementPresent('selected_shared_address-2'); |
| 479 | |
| 480 | // Clicking save. |
| 481 | $this->click("_qf_Contact_upload_view"); |
| 482 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 483 | $name = $this->getText("xpath=//div[@class='crm-summary-display_name']"); |
| 484 | $this->waitForText('crm-notification-container', "$name has been created."); |
| 485 | |
| 486 | //make sure current employer is set |
| 487 | $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div", 'Employer'); |
| 488 | $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div[2]/a[text()]", $currentEmployer); |
| 489 | |
| 490 | //make sure both shared address are set. |
| 491 | $this->assertElementContainsText('address-block-1', "Address belongs to $currentEmployer"); |
| 492 | $this->assertElementContainsText('address-block-2', "Address belongs to $sharedHousehold"); |
| 493 | |
| 494 | // make sure relationships are created |
| 495 | $this->click("xpath=id('tab_rel')/a"); |
| 496 | $this->waitForElementPresent('permission-legend'); |
| 497 | $this->assertElementContainsText('DataTables_Table_0', 'Employee of'); |
| 498 | $this->assertElementContainsText('DataTables_Table_0', 'Household Member of'); |
| 499 | } |
| 500 | |
| 501 | public function testContactDeceased() { |
| 502 | $this->webtestLogin(); |
| 503 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 504 | $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); |
| 505 | //contact details section |
| 506 | //fill in first name |
| 507 | $fname = substr(sha1(rand()), 0, 7) . "John"; |
| 508 | $lname = substr(sha1(rand()), 0, 7) . "Smith"; |
| 509 | $this->type("first_name", $fname); |
| 510 | //fill in last name |
| 511 | $this->type("last_name", $lname); |
| 512 | //fill in email |
| 513 | $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com"); |
| 514 | // Clicking save. |
| 515 | $this->click("_qf_Contact_upload_view"); |
| 516 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 517 | $this->waitForText('crm-notification-container', "Contact Saved"); |
| 518 | //Edit Contact |
| 519 | $cid = $this->urlArg('cid'); |
| 520 | $dname = $fname . ' ' . $lname . ' (deceased)'; |
| 521 | foreach (array('', 'deceased') as $val) { |
| 522 | $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}"); |
| 523 | if ($val) { |
| 524 | $this->assertElementContainsText('page-title', 'Edit ' . $dname); |
| 525 | } |
| 526 | // Click on the Demographics tab |
| 527 | $this->click('demographics'); |
| 528 | $this->waitForElementPresent('is_deceased'); |
| 529 | $this->click('is_deceased'); |
| 530 | // Click on Save |
| 531 | $this->click('_qf_Contact_upload_view-bottom'); |
| 532 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 533 | if (!$val) { |
| 534 | $this->assertElementContainsText('css=div.crm-summary-display_name', $dname); |
| 535 | } |
| 536 | else { |
| 537 | $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname)); |
| 538 | } |
| 539 | } |
| 540 | foreach (array('', 'deceased') as $val) { |
| 541 | $this->mouseDown('crm-demographic-content'); |
| 542 | $this->mouseUp('crm-demographic-content'); |
| 543 | $this->waitForElementPresent("css=#crm-demographic-content .crm-container-snippet form"); |
| 544 | $this->click('is_deceased'); |
| 545 | $this->click("css=#crm-demographic-content input.crm-form-submit"); |
| 546 | $this->waitForElementPresent("css=#crm-demographic-content > .crm-inline-block-content"); |
| 547 | if (!$val) { |
| 548 | $this->assertElementContainsText('css=div.crm-summary-display_name', $dname); |
| 549 | } |
| 550 | else { |
| 551 | $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname)); |
| 552 | } |
| 553 | } |
| 554 | $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}"); |
| 555 | $this->assertTrue(($this->getText('page-title') != $dname)); |
| 556 | } |
| 557 | |
| 558 | } |