Commit | Line | Data |
---|---|---|
41e555ba | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
2fe49090 | 4 | | CiviCRM version 5 | |
41e555ba | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
41e555ba | 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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
41e555ba | 26 | |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contact_EditContactTest | |
31 | */ | |
41e555ba | 32 | class WebTest_Contact_EditContactTest extends CiviSeleniumTestCase { |
33 | protected function setUp() { | |
34 | parent::setUp(); | |
35 | } | |
36 | ||
00be9182 | 37 | public function testEditContact() { |
41e555ba | 38 | // Log in using webtestLogin() method |
39 | $this->webtestLogin(); | |
40 | ||
41 | // create contact | |
fd655174 | 42 | $firstName = 'WebTest' . substr(sha1(rand()), 0, 7); |
92915c55 | 43 | $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7); |
41e555ba | 44 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6c6e6187 TO |
45 | $this->type("first_name", $firstName); |
46 | $this->type("last_name", $lastName); | |
41e555ba | 47 | |
48 | //fill in phone 1 | |
49 | $this->type("phone_1_phone", "111113333"); | |
50 | $this->type("phone_1_phone_ext", "101"); | |
51 | ||
52 | //fill in phone 2 | |
fd655174 | 53 | |
41e555ba | 54 | $this->click("//a[@id='addPhone']"); |
55 | $this->type("phone_2_phone", "23213333"); | |
56 | $this->type("phone_2_phone_ext", "165"); | |
57 | $this->select('phone_2_location_type_id', 'value=2'); | |
58 | ||
59 | //fill in phone 3 | |
60 | $this->click("//a[@id='addPhone']"); | |
61 | $this->type("phone_3_phone", "2321877699"); | |
62 | $this->type("phone_3_phone_ext", "195"); | |
63 | $this->select('phone_3_location_type_id', 'value=2'); | |
64 | ||
65 | //fill in phone 4 | |
66 | $this->click("//a[@id='addPhone']"); | |
67 | $this->type("phone_4_phone", "2321398766"); | |
68 | $this->type("phone_4_phone_ext", "198"); | |
69 | $this->select('phone_4_location_type_id', 'value=2'); | |
70 | ||
71 | // Submit form | |
72 | $this->click("_qf_Contact_upload_view-bottom"); | |
73 | $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready'); | |
74 | ||
fd655174 | 75 | //assert |
76 | $this->assertTextPresent("111113333 ext. 101"); | |
77 | $this->assertTextPresent("23213333 ext. 165"); | |
78 | $this->assertTextPresent("2321877699 ext. 195"); | |
79 | $this->assertTextPresent("2321398766 ext. 198"); | |
80 | ||
41e555ba | 81 | //Edit COntact |
82 | $cid = $this->urlArg('cid'); | |
83 | $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}"); | |
84 | ||
fd655174 | 85 | //Edit in phone 1 |
86 | $this->type("phone_1_phone", "12223333"); | |
87 | $this->type("phone_1_phone_ext", "100"); | |
88 | ||
41e555ba | 89 | //Edit in phone 2 |
90 | $this->type("phone_2_phone", "2321800000"); | |
91 | $this->type("phone_2_phone_ext", "111"); | |
92 | $this->select('phone_2_location_type_id', 'value=3'); | |
93 | ||
6c6e6187 | 94 | //Edit in phone 3 |
41e555ba | 95 | $this->type("phone_3_phone", "777777699"); |
fd655174 | 96 | $this->type("phone_3_phone_ext", "197"); |
41e555ba | 97 | $this->select('phone_3_location_type_id', 'value=1'); |
98 | ||
99 | //Edit in phone 4 | |
100 | $this->type("phone_4_phone", "2342322222"); | |
101 | $this->type("phone_4_phone_ext", "198"); | |
102 | $this->select('phone_4_location_type_id', 'value=3'); | |
103 | ||
104 | // Submit form | |
105 | $this->click("_qf_Contact_upload_view-bottom"); | |
106 | $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready'); | |
107 | ||
108 | //assert | |
fd655174 | 109 | $this->assertTextPresent("12223333 ext. 100"); |
41e555ba | 110 | $this->assertTextPresent("2321800000 ext. 111"); |
fd655174 | 111 | $this->assertTextPresent("777777699 ext. 197"); |
41e555ba | 112 | $this->assertTextPresent("2342322222 ext. 198"); |
113 | ||
114 | } | |
96025800 | 115 | |
1a03f246 WA |
116 | /** |
117 | * CRM-17273 | |
118 | */ | |
3f3c7581 WA |
119 | public function testdisallowEditLocationType() { |
120 | $this->webtestLogin(); | |
121 | ||
122 | // create contact | |
123 | $firstName = 'WebTest' . substr(sha1(rand()), 0, 7); | |
124 | $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7); | |
125 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); | |
126 | $this->waitForElementPresent('_qf_Contact_cancel-bottom'); | |
127 | ||
128 | $this->type("first_name", $firstName); | |
129 | $this->type("last_name", $lastName); | |
130 | ||
131 | //fill email | |
132 | $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "email1@gmail.com"); | |
133 | $this->click("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[1]/td[1]/a[text()='add']"); | |
134 | $this->waitForElementPresent('email_2_email'); | |
135 | $this->type("email_2_email", substr(sha1(rand()), 0, 7) . "email2@gmail.com"); | |
136 | ||
137 | //fill in phone 1 | |
138 | $this->type("phone_1_phone", "111113333"); | |
139 | $this->type("phone_1_phone_ext", "101"); | |
140 | ||
141 | //fill in IM | |
142 | $this->type("im_1_name", "testYahoo"); | |
143 | ||
144 | //address section | |
145 | $this->click("addressBlock"); | |
146 | $this->waitForElementPresent("address_1_street_address"); | |
147 | //fill in address 1 | |
148 | $this->type("address_1_street_address", "902C El Camino Way SW"); | |
149 | $this->type("address_1_city", "Dumfries"); | |
150 | $this->type("address_1_postal_code", "1234"); | |
151 | ||
152 | // Submit form | |
153 | $this->click("_qf_Contact_upload_view-top"); | |
154 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
155 | ||
156 | // Get Contact id | |
157 | $cid = $this->urlArg('cid'); | |
158 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid"); | |
159 | ||
160 | $this->waitForElementPresent('_qf_Contact_cancel-bottom'); | |
161 | $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='Email_Block_1']/td[1]/a/i"); | |
162 | $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='Email_Block_2']/td[1]/a/i"); | |
163 | $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='Phone_Block_1']/td[2]/a/i"); | |
164 | $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='IM_Block_1']/td[2]/a/i"); | |
165 | ||
166 | $this->click("addressBlockId"); | |
167 | $this->waitForElementNotPresent("xpath=//div[@id='addressBlock']/div/table/tbody/tr[1]/td[1]/span[1]/a/i"); | |
168 | } | |
169 | ||
41e555ba | 170 | } |