4241b7e5969a989f62d1ae5297295f2b41a1d8e2
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Contact_AddTest
32 class WebTest_Contact_AddTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testIndividualAdd() {
39 $this->webtestLogin();
41 $groupName = $this->WebtestAddGroup();
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->waitForAjaxContent();
46 if (!$this->isChecked("xpath=//ul[@id='contactEditBlocks']//li[@id='preference-10-contactedit']/span/input")) {
47 $this->click("xpath=//ul[@id='contactEditBlocks']//li/span/label[text()='Open ID']");
49 $this->click("_qf_Display_next-bottom");
50 $this->waitForPageToLoad($this->getTimeoutMsec());
51 $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
53 //contact details section
55 $this->click("prefix_id");
56 $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
59 $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
62 $this->type("middle_name", "Bruce");
65 $this->type("last_name", substr(sha1(rand()), 0, 7) . "Smith");
68 $this->select("suffix_id", "value=3");
71 $this->type("nick_name", "jsmith");
74 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
77 $this->type("phone_1_phone", "2222-4444");
80 $this->type("im_1_name", "testYahoo");
83 $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "openid.com");
86 $this->type("website_1_url", "http://www.john.com");
89 $this->type("contact_source", "johnSource");
91 //fill in external identifier
92 $indExternalId = substr(sha1(rand()), 0, 4);
93 $this->type("external_identifier", $indExternalId);
95 //check for matching contact
96 $this->click("_qf_Contact_refresh_dedupe");
97 $this->waitForPageToLoad($this->getTimeoutMsec());
100 $this->click("addressBlock");
101 $this->waitForElementPresent("address_1_street_address");
103 $this->type("address_1_street_address", "902C El Camino Way SW");
104 $this->type("address_1_city", "Dumfries");
105 $this->type("address_1_postal_code", "1234");
107 $this->click("address_1_country_id");
108 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
110 if ($this->assertElementContainsText('address_table_1', "Latitude")) {
111 $this->type("address_1_geo_code_1", "1234");
112 $this->type("address_1_geo_code_2", "5678");
116 $this->click("//div[@id='addMoreAddress1']/a/span");
117 $this->waitForElementPresent("address_2_street_address");
118 $this->type("address_2_street_address", "2782Y Dowlen Path W");
119 $this->type("address_2_city", "Birmingham");
120 $this->type("address_2_postal_code", "3456");
122 $this->click("address_2_country_id");
123 $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID());
125 if ($this->assertElementContainsText('address_table_2', "Latitude")) {
126 $this->type("address_2_geo_code_1", "1234");
127 $this->type("address_2_geo_code_2", "5678");
130 //Communication Preferences section
131 $this->click("commPrefs");
133 //select greeting/addressee options
134 $this->waitForElementPresent("email_greeting_id");
135 $this->select("email_greeting_id", "value=2");
136 $this->select("postal_greeting_id", "value=3");
138 //Select preferred method for Privacy
139 $this->click("privacy[do_not_trade]");
140 $this->click("privacy[do_not_sms]");
142 //Select preferred method(s) of communication
143 $this->click("preferred_communication_method[1]");
144 $this->click("preferred_communication_method[2]");
146 //select preferred language
147 $this->waitForElementPresent("preferred_language");
148 $this->select("preferred_language", "value=en_US");
151 $this->click("notesBlock");
152 $this->waitForElementPresent("subject");
153 $this->type("subject", "test note");
154 $this->type("note", "this is a test note contact webtest");
155 $this->assertElementContainsText('notesBlock', "Subject\n Note");
157 //Demographics section
158 $this->click("//div[@class='crm-accordion-header' and contains(.,'Demographics')]");
159 $this->waitForElementPresent("birth_date");
161 $this->webtestFillDate('birth_date', "-1 year");
163 //Tags and Groups section
164 $this->click("tagGroup");
167 $this->select("group", "label=$groupName");
168 $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
171 $this->click("_qf_Contact_upload_view");
173 $this->waitForPageToLoad($this->getTimeoutMsec());
174 $this->waitForText('crm-notification-container', "Contact Saved");
177 public function testHouseholdAdd() {
178 $this->webtestLogin();
180 $groupName = $this->WebtestAddGroup();
182 // go to display preferences to enable Open ID field
183 $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom");
184 $this->waitForAjaxContent();
185 if (!$this->isChecked("xpath=//ul[@id='contactEditBlocks']//li[@id='preference-10-contactedit']/span/input")) {
186 $this->click("xpath=//ul[@id='contactEditBlocks']//li/span/label[text()='Open ID']");
188 $this->click("_qf_Display_next-bottom");
189 $this->waitForPageToLoad($this->getTimeoutMsec());
191 $this->openCiviPage('contact/add', "reset=1&ct=Household");
193 //contact details section
194 //fill in Household name
195 $this->click("household_name");
196 $name = substr(sha1(rand()), 0, 7) . "Fraddie Grant's home ";
197 $this->type("household_name", $name);
200 $this->type("nick_name", substr(sha1(rand()), 0, 7) . "Grant's home");
203 $email = substr(sha1(rand()), 0, 7) . "fraddiegrantshome@web.com ";
204 $this->type("email_1_email", $email);
205 $this->click("Email_1_IsBulkmail");
208 $this->type("phone_1_phone", "444-4444");
209 $this->select("phone_1_phone_type_id", "value=" . $this->webtestGetFirstValueForOptionGroup('phone_type'));
212 foreach (array('Yahoo', 'MSN', 'AIM', 'GTalk', 'Jabber', 'Skype') as $option) {
213 $this->assertSelectHasOption('im_1_provider_id', $option);
215 $this->type("im_1_name", "testSkype");
216 $this->select("im_1_location_type_id", "value=3");
217 $this->select("im_1_provider_id", "value=6");
220 $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "shomeopenid.com");
222 //fill in website url
223 $this->type("website_1_url", "http://www.fraddiegrantshome.com");
225 //fill in contact source
226 $this->type("contact_source", "Grant's home source");
228 //fill in external identifier
229 $houExternalId = substr(sha1(rand()), 0, 4);
230 $this->type("external_identifier", $houExternalId);
232 //check for duplicate contact
233 $this->click("_qf_Contact_refresh_dedupe");
234 $this->waitForPageToLoad($this->getTimeoutMsec());
237 $this->click("addressBlock");
238 $this->waitForElementPresent("address_1_street_address");
239 $this->type("address_1_street_address", "938U Bay Rd E");
240 $this->type("address_1_city", "Birmingham");
241 $this->type("address_1_postal_code", "35278");
243 $this->click("address_1_country_id");
244 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
246 if ($this->assertElementContainsText('address_table_1', "Latitude")) {
247 $this->type("address_1_geo_code_1", "1234");
248 $this->type("address_1_geo_code_2", "5678");
251 //Communication Preferences section
252 $this->click("commPrefs");
254 //select greeting/addressee options
255 $this->waitForElementPresent("addressee_id");
256 $this->select("addressee_id", "value=4");
257 $this->type("addressee_custom", "Grant's home");
259 //Select preferred method(s) of communication
260 $this->click("preferred_communication_method[1]");
261 $this->click("preferred_communication_method[2]");
262 $this->click("preferred_communication_method[5]");
264 //Select preferred method for Privacy
265 $this->click("privacy[do_not_sms]");
267 //select preferred language
268 $this->waitForElementPresent("preferred_language");
269 $this->select("preferred_language", "value=fr_FR");
272 $this->clickAt("//*[@id='Contact']/div[2]/div[6]/div[1]");
273 $this->waitForElementPresent("subject");
274 $this->type("subject", "Grant's note");
275 $this->type("note", "This is a household contact webtest note.");
278 $this->clickAt("xpath=//div[text()='Tags and Groups']");
279 $this->select("group", "label=$groupName");
282 $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
285 $this->click("_qf_Contact_upload_view");
286 $this->waitForPageToLoad($this->getTimeoutMsec());
288 $this->waitForText('crm-notification-container', "Contact Saved");
291 public function testOrganizationAdd() {
292 $this->webtestLogin();
294 $groupName = $this->WebtestAddGroup();
296 // go to display preferences to enable Open ID field
297 $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom");
298 $this->waitForAjaxContent();
299 if (!$this->isChecked("xpath=//ul[@id='contactEditBlocks']//li[@id='preference-10-contactedit']/span/input")) {
300 $this->click("xpath=//ul[@id='contactEditBlocks']//li/span/label[text()='Open ID']");
302 $this->click("_qf_Display_next-bottom");
303 $this->waitForPageToLoad($this->getTimeoutMsec());
305 $this->openCiviPage('contact/add', 'reset=1&ct=Organization');
307 //contact details section
308 //fill in Organization name
309 $this->click("organization_name");
310 $this->type("organization_name", substr(sha1(rand()), 0, 7) . "syntel tech");
313 $this->type("legal_name", "syntel tech Ltd");
316 $this->type("nick_name", "syntel");
319 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "info@syntel.com");
322 $this->type("phone_1_phone", "222-7777");
323 $this->select("phone_1_phone_type_id", "value=2");
326 $this->type("im_1_name", "testGtalk");
327 $this->select("im_1_location_type_id", "value=4");
328 $this->select("im_1_provider_id", "value=4");
331 $this->select("openid_1_location_type_id", "value=5");
332 $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "Openid.com");
334 //fill in website url
335 $this->type("website_1_url", "http://syntelglobal.com");
337 //fill in contact source
338 $this->type("contact_source", "syntel's source");
340 //fill in external identifier
341 $orgExternalId = substr(sha1(rand()), 0, 4);
342 $this->type("external_identifier", $orgExternalId);
344 //check for duplicate contact
345 $this->click("_qf_Contact_refresh_dedupe");
346 $this->waitForPageToLoad($this->getTimeoutMsec());
349 $this->click("addressBlock");
350 $this->waitForElementPresent("address_1_street_address");
351 $this->type("address_1_street_address", "928A Lincoln Way W");
352 $this->type("address_1_city", "Madison");
353 $this->type("address_1_postal_code", "68748");
355 $this->click("address_1_country_id");
356 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
358 if ($this->assertElementContainsText('address_table_1', "Latitude")) {
359 $this->type("address_1_geo_code_1", "1234");
360 $this->type("address_1_geo_code_2", "5678");
363 //Communication Preferences section
364 $this->click("commPrefs");
366 //Select preferred method(s) of communication
367 $this->click("preferred_communication_method[2]");
368 $this->click("preferred_communication_method[5]");
370 //Select preferred method for Privacy
371 $this->click("privacy[do_not_sms]");
372 $this->click("privacy[do_not_mail]");
373 //select preferred language
374 $this->waitForElementPresent("preferred_language");
375 $this->select("preferred_language", "value=de_DE");
378 $this->click("notesBlock");
379 $this->waitForElementPresent("subject");
380 $this->type("subject", "syntel global note");
381 $this->type("note", "This is a note for syntel global's contact webtest.");
383 //Tags and Groups section
384 $this->click("tagGroup");
387 $this->select("group", "label=$groupName");
389 $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
392 $this->click("_qf_Contact_upload_view");
393 $this->waitForPageToLoad($this->getTimeoutMsec());
395 $this->waitForText('crm-notification-container', "Contact Saved");
398 public function testIndividualAddWithSharedAddress() {
399 $this->webtestLogin();
401 $this->openCiviPage('contact/add', "reset=1&ct=Individual");
403 //contact details section
405 $this->click("prefix_id");
406 $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
409 $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
411 //fill in middle name
412 $this->type("middle_name", "Bruce");
414 $lastName = substr(sha1(rand()), 0, 7) . "Smith";
416 $this->type("last_name", $lastName);
418 //create new current employer
419 $currentEmployer = substr(sha1(rand()), 0, 7) . "Web Access";
422 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
425 $this->type("phone_1_phone", "2222-4444");
428 $this->type("contact_source", "johnSource");
431 $this->click("addressBlock");
432 $this->waitForElementPresent("address_1_street_address");
434 $this->select('address_1_location_type_id', 'value=2');
436 $this->click('address[1][use_shared_address]');
438 // create new organization with dialog
439 $this->clickAt("xpath=//div[@id='s2id_address_1_master_contact_id']/a");
440 $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]");
442 // create new contact using dialog
443 $this->waitForElementPresent("css=div#crm-profile-block");
444 $this->waitForElementPresent("_qf_Edit_next");
446 $this->type('organization_name', $currentEmployer);
447 $this->type('street_address-1', '902C El Camino Way SW');
448 $this->type("email-Primary", "john@gmail.com" . substr(sha1(rand()), 0, 7));
449 $this->type('city-1', 'Dumfries');
450 $this->type('postal_code-1', '1234');
451 $this->select('state_province-1', 'value=1001');
453 $this->click("_qf_Edit_next");
455 $this->select2('employer_id', $currentEmployer);
457 //make sure shared address is selected
458 $this->waitForElementPresent('selected_shared_address-1');
461 $this->click("//div[@id='addMoreAddress1']/a/span");
462 $this->waitForElementPresent("address_2_street_address");
464 $this->select('address_2_location_type_id', 'value=1');
466 $this->click('address[2][use_shared_address]');
468 // create new household with dialog
469 $this->clickAt("xpath=//div[@id='s2id_address_2_master_contact_id']/a");
470 $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Household')]");
472 // create new contact using dialog
473 $this->waitForElementPresent("css=div#crm-profile-block");
474 $this->waitForElementPresent("_qf_Edit_next");
476 $sharedHousehold = substr(sha1(rand()), 0, 7) . 'Smith Household';
477 $this->type('household_name', $sharedHousehold);
478 $this->type('street_address-1', '2782Y Dowlen Path W');
479 $this->type("email-Primary", substr(sha1(rand()), 0, 7) . "john@gmail.com");
480 $this->type('city-1', 'Birmingham');
481 $this->type('postal_code-1', '3456');
482 $this->select('state_province-1', 'value=1001');
484 $this->click("_qf_Edit_next");
486 //make sure shared address is selected
487 $this->waitForElementPresent('selected_shared_address-2');
490 $this->click("_qf_Contact_upload_view");
491 $this->waitForPageToLoad($this->getTimeoutMsec());
492 $name = $this->getText("xpath=//div[@class='crm-summary-display_name']");
493 $this->waitForText('crm-notification-container', "$name has been created.");
495 //make sure current employer is set
496 $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div", 'Employer');
497 $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div[2]/a[text()]", $currentEmployer);
499 //make sure both shared address are set.
500 $this->assertElementContainsText('address-block-1', "Address belongs to $currentEmployer");
501 $this->assertElementContainsText('address-block-2', "Address belongs to $sharedHousehold");
503 // make sure relationships are created
504 $this->click("xpath=id('tab_rel')/a");
505 $this->waitForElementPresent('permission-legend');
506 $this->assertElementContainsText('DataTables_Table_0', 'Employee of');
507 $this->assertElementContainsText('DataTables_Table_0', 'Household Member of');
510 public function testContactDeceased() {
511 $this->webtestLogin();
512 $this->waitForPageToLoad($this->getTimeoutMsec());
513 $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
514 //contact details section
516 $fname = substr(sha1(rand()), 0, 7) . "John";
517 $lname = substr(sha1(rand()), 0, 7) . "Smith";
518 $this->type("first_name", $fname);
520 $this->type("last_name", $lname);
522 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
524 $this->click("_qf_Contact_upload_view");
525 $this->waitForPageToLoad($this->getTimeoutMsec());
526 $this->waitForText('crm-notification-container', "Contact Saved");
528 $cid = $this->urlArg('cid');
529 $dname = $fname . ' ' . $lname . ' (deceased)';
530 foreach (array('', 'deceased') as $val) {
531 $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
533 $this->assertElementContainsText('page-title', 'Edit ' . $dname);
535 // Click on the Demographics tab
536 $this->click('demographics');
537 $this->waitForElementPresent('is_deceased');
538 $this->click('is_deceased');
540 $this->click('_qf_Contact_upload_view-bottom');
541 $this->waitForPageToLoad($this->getTimeoutMsec());
543 $this->assertElementContainsText('css=div.crm-summary-display_name', $dname);
546 $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname));
549 foreach (array('', 'deceased') as $val) {
550 $this->mouseDown('crm-demographic-content');
551 $this->mouseUp('crm-demographic-content');
552 $this->waitForElementPresent("css=#crm-demographic-content .crm-container-snippet form");
553 $this->click('is_deceased');
554 $this->click("css=#crm-demographic-content input.crm-form-submit");
555 $this->waitForElementPresent("css=#crm-demographic-content > .crm-inline-block-content");
557 $this->assertElementContainsText('css=div.crm-summary-display_name', $dname);
560 $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname));
563 $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
564 $this->assertTrue(($this->getText('page-title') != $dname));