9249b549fa6a481e08b46d31392babe4b531a34a
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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->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');
50 //contact details section
52 $this->click("prefix_id");
53 $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
56 $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
59 $this->type("middle_name", "Bruce");
62 $this->type("last_name", substr(sha1(rand()), 0, 7) . "Smith");
65 $this->select("suffix_id", "value=3");
68 $this->type("nick_name", "jsmith");
71 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
74 $this->type("phone_1_phone", "2222-4444");
77 $this->type("im_1_name", "testYahoo");
80 $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "openid.com");
83 $this->type("website_1_url", "http://www.john.com");
86 $this->type("contact_source", "johnSource");
88 //fill in external identifier
89 $indExternalId = substr(sha1(rand()), 0, 4);
90 $this->type("external_identifier", $indExternalId);
92 //check for matching contact
93 $this->click("_qf_Contact_refresh_dedupe");
94 $this->waitForPageToLoad($this->getTimeoutMsec());
97 $this->click("addressBlock");
98 $this->waitForElementPresent("address_1_street_address");
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");
104 $this->click("address_1_country_id");
105 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
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");
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");
119 $this->click("address_2_country_id");
120 $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID());
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");
127 //Communication Preferences section
128 $this->click("commPrefs");
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");
135 //Select preferred method for Privacy
136 $this->click("privacy[do_not_trade]");
137 $this->click("privacy[do_not_sms]");
139 //Select preferred method(s) of communication
140 $this->click("preferred_communication_method[1]");
141 $this->click("preferred_communication_method[2]");
143 //select preferred language
144 $this->waitForElementPresent("preferred_language");
145 $this->select("preferred_language", "value=en_US");
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 Notes");
154 //Demographics section
155 $this->click("//div[@class='crm-accordion-header' and contains(.,'Demographics')]");
156 $this->waitForElementPresent("birth_date");
158 $this->webtestFillDate('birth_date', "-1 year");
160 //Tags and Groups section
161 $this->click("tagGroup");
164 $this->select("group", "label=$groupName");
165 $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
168 $this->click("_qf_Contact_upload_view");
170 $this->waitForPageToLoad($this->getTimeoutMsec());
171 $this->waitForText('crm-notification-container', "Contact Saved");
174 public function testHouseholdAdd() {
175 $this->webtestLogin();
177 $groupName = $this->WebtestAddGroup();
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());
185 $this->openCiviPage('contact/add', "reset=1&ct=Household");
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);
194 $this->type("nick_name", substr(sha1(rand()), 0, 7) . "Grant's home");
197 $email = substr(sha1(rand()), 0, 7) . "fraddiegrantshome@web.com ";
198 $this->type("email_1_email", $email);
199 $this->click("Email_1_IsBulkmail");
202 $this->type("phone_1_phone", "444-4444");
203 $this->select("phone_1_phone_type_id", "value=" . $this->webtestGetFirstValueForOptionGroup('phone_type'));
206 foreach (array('Yahoo', 'MSN', 'AIM', 'GTalk', 'Jabber', 'Skype') as $option) {
207 $this->assertSelectHasOption('im_1_provider_id', $option);
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");
214 $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "shomeopenid.com");
216 //fill in website url
217 $this->type("website_1_url", "http://www.fraddiegrantshome.com");
219 //fill in contact source
220 $this->type("contact_source", "Grant's home source");
222 //fill in external identifier
223 $houExternalId = substr(sha1(rand()), 0, 4);
224 $this->type("external_identifier", $houExternalId);
226 //check for duplicate contact
227 $this->click("_qf_Contact_refresh_dedupe");
228 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
237 $this->click("address_1_country_id");
238 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
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");
245 //Communication Preferences section
246 $this->click("commPrefs");
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");
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]");
258 //Select preferred method for Privacy
259 $this->click("privacy[do_not_sms]");
261 //select preferred language
262 $this->waitForElementPresent("preferred_language");
263 $this->select("preferred_language", "value=fr_FR");
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.");
272 $this->clickAt("xpath=//div[text()='Tags and Groups']");
273 $this->select("group", "label=$groupName");
276 $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
279 $this->click("_qf_Contact_upload_view");
280 $this->waitForPageToLoad($this->getTimeoutMsec());
282 $this->waitForText('crm-notification-container', "Contact Saved");
285 public function testOrganizationAdd() {
286 $this->webtestLogin();
288 $groupName = $this->WebtestAddGroup();
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());
296 $this->openCiviPage('contact/add', 'reset=1&ct=Organization');
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");
304 $this->type("legal_name", "syntel tech Ltd");
307 $this->type("nick_name", "syntel");
310 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "info@syntel.com");
313 $this->type("phone_1_phone", "222-7777");
314 $this->select("phone_1_phone_type_id", "value=2");
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");
322 $this->select("openid_1_location_type_id", "value=5");
323 $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "Openid.com");
325 //fill in website url
326 $this->type("website_1_url", "http://syntelglobal.com");
328 //fill in contact source
329 $this->type("contact_source", "syntel's source");
331 //fill in external identifier
332 $orgExternalId = substr(sha1(rand()), 0, 4);
333 $this->type("external_identifier", $orgExternalId);
335 //check for duplicate contact
336 $this->click("_qf_Contact_refresh_dedupe");
337 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
346 $this->click("address_1_country_id");
347 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
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");
354 //Communication Preferences section
355 $this->click("commPrefs");
357 //Select preferred method(s) of communication
358 $this->click("preferred_communication_method[2]");
359 $this->click("preferred_communication_method[5]");
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");
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.");
374 //Tags and Groups section
375 $this->click("tagGroup");
378 $this->select("group", "label=$groupName");
380 $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
383 $this->click("_qf_Contact_upload_view");
384 $this->waitForPageToLoad($this->getTimeoutMsec());
386 $this->waitForText('crm-notification-container', "Contact Saved");
389 public function testIndividualAddWithSharedAddress() {
390 $this->webtestLogin();
392 $this->openCiviPage('contact/add', "reset=1&ct=Individual");
394 //contact details section
396 $this->click("prefix_id");
397 $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
400 $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
402 //fill in middle name
403 $this->type("middle_name", "Bruce");
405 $lastName = substr(sha1(rand()), 0, 7) . "Smith";
407 $this->type("last_name", $lastName);
409 //create new current employer
410 $currentEmployer = substr(sha1(rand()), 0, 7) . "Web Access";
413 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
416 $this->type("phone_1_phone", "2222-4444");
419 $this->type("contact_source", "johnSource");
422 $this->click("addressBlock");
423 $this->waitForElementPresent("address_1_street_address");
425 $this->select('address_1_location_type_id', 'value=2');
427 $this->click('address[1][use_shared_address]');
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')]");
433 // create new contact using dialog
434 $this->waitForElementPresent("css=div#crm-profile-block");
435 $this->waitForElementPresent("_qf_Edit_next");
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');
444 $this->click("_qf_Edit_next");
446 $this->select2('employer_id', $currentEmployer);
448 //make sure shared address is selected
449 $this->waitForElementPresent('selected_shared_address-1');
452 $this->click("//div[@id='addMoreAddress1']/a/span");
453 $this->waitForElementPresent("address_2_street_address");
455 $this->select('address_2_location_type_id', 'value=1');
457 $this->click('address[2][use_shared_address]');
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')]");
463 // create new contact using dialog
464 $this->waitForElementPresent("css=div#crm-profile-block");
465 $this->waitForElementPresent("_qf_Edit_next");
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');
475 $this->click("_qf_Edit_next");
477 //make sure shared address is selected
478 $this->waitForElementPresent('selected_shared_address-2');
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.");
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);
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");
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');
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
507 $fname = substr(sha1(rand()), 0, 7) . "John";
508 $lname = substr(sha1(rand()), 0, 7) . "Smith";
509 $this->type("first_name", $fname);
511 $this->type("last_name", $lname);
513 $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
515 $this->click("_qf_Contact_upload_view");
516 $this->waitForPageToLoad($this->getTimeoutMsec());
517 $this->waitForText('crm-notification-container', "Contact Saved");
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}");
524 $this->assertElementContainsText('page-title', 'Edit ' . $dname);
526 // Click on the Demographics tab
527 $this->click('demographics');
528 $this->waitForElementPresent('is_deceased');
529 $this->click('is_deceased');
531 $this->click('_qf_Contact_upload_view-bottom');
532 $this->waitForPageToLoad($this->getTimeoutMsec());
534 $this->assertElementContainsText('css=div.crm-summary-display_name', $dname);
537 $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname));
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");
548 $this->assertElementContainsText('css=div.crm-summary-display_name', $dname);
551 $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname));
554 $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
555 $this->assertTrue(($this->getText('page-title') != $dname));