Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
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 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Profile_SearchTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testSearchProfile() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
6d2387a1 PJ |
41 | // enable county field |
42 | $this->openCiviPage('admin/setting/preferences/address', 'reset=1'); | |
43 | $this->check('address_options[7]'); | |
44 | $this->clickLink('_qf_Address_next-bottom'); | |
45 | ||
6a488035 | 46 | // Add new profile. |
305515fb | 47 | $this->openCiviPage('admin/uf/group', 'reset=1'); |
76e86fd8 | 48 | |
6a488035 TO |
49 | $this->click('newCiviCRMProfile-bottom'); |
50 | ||
51 | $this->waitForElementPresent('_qf_Group_next-bottom'); | |
52 | ||
53 | //Name of profile | |
54 | $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7); | |
55 | $this->type('title', $profileTitle); | |
56 | ||
3379d026 | 57 | $this->click('uf_group_type_Profile'); |
6a488035 TO |
58 | //click on save |
59 | $this->click('_qf_Group_next-bottom'); | |
60 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1b1cbb04 | 61 | $this->waitForElementPresent("_qf_Field_next-bottom"); |
6a488035 TO |
62 | |
63 | //check for profile create | |
6c5f7368 | 64 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); |
6a488035 TO |
65 | |
66 | // Get profile id (gid) from URL | |
a471a3b6 | 67 | $profileId = $this->urlArg('gid'); |
6a488035 TO |
68 | |
69 | // Add Last Name field. | |
bf2c3b74 | 70 | $this->waitForElementPresent("field_name[0]"); |
6a488035 TO |
71 | $this->click('field_name[0]'); |
72 | $this->select('field_name[0]', 'value=Individual'); | |
73 | $this->click('field_name[1]'); | |
74 | $this->select('field_name[1]', 'value=last_name'); | |
75 | $this->click("//option[@value='Individual']"); | |
76 | $this->click('visibility'); | |
77 | $this->select('visibility', 'value=Public Pages'); | |
78 | $this->click('is_searchable'); | |
79 | $this->click('in_selector'); | |
80 | // click on save | |
81 | $this->click('_qf_Field_next_new-bottom'); | |
6a488035 | 82 | //check for field add |
6c5f7368 | 83 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'."); |
305515fb | 84 | |
6a488035 TO |
85 | // Add Email field. |
86 | $this->click('field_name[0]'); | |
87 | $this->select('field_name[0]', 'value=Contact'); | |
88 | $this->click('field_name[1]'); | |
89 | $this->select('field_name[1]', 'value=email'); | |
90 | $this->click("//option[@value='Contact']"); | |
91 | $this->click('visibility'); | |
92 | $this->select('visibility', 'value=Public Pages'); | |
93 | $this->click('is_searchable'); | |
94 | $this->click('in_selector'); | |
95 | // click on save | |
96 | $this->click('_qf_Field_next_new-bottom'); | |
6a488035 | 97 | //check for field add |
6c5f7368 | 98 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'."); |
6a488035 TO |
99 | |
100 | // Add Sample Custom Field. | |
101 | $this->click('field_name[0]'); | |
102 | $this->select('field_name[0]', 'value=Individual'); | |
103 | $this->click('field_name[1]'); | |
104 | $this->select('field_name[1]', 'value=custom_1'); | |
105 | $this->click("//option[@value='Individual']"); | |
106 | $this->click('visibility'); | |
107 | $this->select('visibility', 'value=Public Pages'); | |
108 | $this->click('is_searchable'); | |
109 | $this->click('in_selector'); | |
bf2c3b74 | 110 | $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE); |
111 | $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']"); | |
6d2387a1 PJ |
112 | |
113 | // Add state, country and county field | |
114 | $this->click('field_name[0]'); | |
115 | $this->select('field_name[0]', 'value=Contact'); | |
116 | $this->click('field_name[1]'); | |
117 | $this->select('field_name[1]', 'value=country'); | |
118 | $this->select('field_name[2]', 'Primary'); | |
119 | $this->click('visibility'); | |
120 | $this->select('visibility', 'value=Public Pages and Listings'); | |
121 | $this->click('is_searchable'); | |
122 | $this->click('in_selector'); | |
123 | // click on save and new | |
bf2c3b74 | 124 | $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE); |
125 | $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']"); | |
6d2387a1 PJ |
126 | |
127 | $this->click('field_name[0]'); | |
128 | $this->select('field_name[0]', 'value=Contact'); | |
129 | $this->click('field_name[1]'); | |
130 | $this->select('field_name[1]', 'value=state_province'); | |
131 | $this->select('field_name[2]', 'Primary'); | |
132 | $this->click('visibility'); | |
133 | $this->select('visibility', 'value=Public Pages and Listings'); | |
134 | $this->click('is_searchable'); | |
135 | $this->click('in_selector'); | |
136 | // click on save and new | |
bf2c3b74 | 137 | $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE); |
138 | $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']"); | |
6d2387a1 PJ |
139 | |
140 | $this->click('field_name[0]'); | |
141 | $this->select('field_name[0]', 'value=Contact'); | |
142 | $this->click('field_name[1]'); | |
143 | $this->select('field_name[1]', 'value=county'); | |
144 | $this->select('field_name[2]', 'Primary'); | |
145 | $this->click('visibility'); | |
146 | $this->select('visibility', 'value=Public Pages and Listings'); | |
147 | $this->click('is_searchable'); | |
148 | $this->click('in_selector'); | |
149 | ||
89d6437d | 150 | // click on save and new |
151 | $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE); | |
152 | $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']"); | |
153 | ||
154 | $this->select('field_name[0]', 'value=Individual'); | |
155 | $this->select('field_name[1]', 'value=current_employer'); | |
156 | $this->select('visibility', 'value=Public Pages and Listings'); | |
157 | $this->click('is_searchable'); | |
158 | $this->click('in_selector'); | |
159 | ||
6a488035 | 160 | // click on save |
1b1cbb04 | 161 | $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span[text()=' Use (create mode)']", FALSE); |
6a488035 | 162 | |
3379d026 | 163 | $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href")); |
39a2888d | 164 | $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_next'); |
6a488035 | 165 | $lastName = substr(sha1(rand()), 0, 7); |
92fcb95f | 166 | $orgName = 'Organisation' . substr(sha1(rand()), 0, 7); |
6a488035 TO |
167 | |
168 | // Fill Last Name | |
169 | $this->type('last_name', $lastName); | |
170 | // Fill Email | |
171 | $this->type('email-Primary', "jhon@$lastName.com"); | |
172 | // Select Custom option | |
173 | $this->click('CIVICRM_QFID_Edu_2'); | |
6d2387a1 PJ |
174 | |
175 | // fill country, state, county | |
176 | $this->select('country-Primary', "United States"); | |
39a2888d CW |
177 | |
178 | // wait for state data to be populated | |
179 | $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']"); | |
6d2387a1 | 180 | $this->select('state_province-Primary', "California"); |
39a2888d CW |
181 | |
182 | // wait for county data to be populated | |
183 | $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']"); | |
6d2387a1 | 184 | $this->select('county-Primary', "Alameda"); |
39a2888d | 185 | |
89d6437d | 186 | $this->type('current_employer', $orgName); |
187 | ||
39a2888d | 188 | $this->clickLink('_qf_Edit_next', NULL); |
305515fb | 189 | |
3379d026 | 190 | $this->assertElementContainsText("css=span.msg-text", 'Your information has been saved.'); |
6a488035 TO |
191 | |
192 | // Search Contact via profile. | |
193 | $this->waitForElementPresent("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']"); | |
194 | $this->click("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']"); | |
195 | $this->waitForElementPresent("xpath=//div[@class='crm-block crm-form-block']"); | |
196 | $this->click("xpath=//div[@class='crm-block crm-form-block']"); | |
197 | // Fill Last Name | |
198 | $this->type('last_name', $lastName); | |
199 | // Fill Email | |
200 | $this->type('email-Primary', "jhon@$lastName.com"); | |
6d2387a1 PJ |
201 | |
202 | // Fill state, county, country | |
203 | $this->select('country-Primary', "United States"); | |
39a2888d CW |
204 | |
205 | // wait for state data to be populated | |
206 | $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']"); | |
6d2387a1 | 207 | $this->select('state_province-Primary', "California"); |
39a2888d CW |
208 | |
209 | // wait for county data to be populated | |
210 | $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']"); | |
6d2387a1 PJ |
211 | $this->select('county-Primary', "Alameda"); |
212 | ||
6a488035 | 213 | // Select Custom option |
bf2c3b74 | 214 | $this->select('custom_1', 'Education'); |
39a2888d | 215 | $this->clickLink('_qf_Search_refresh', NULL); |
6a488035 TO |
216 | |
217 | // Verify Data. | |
305515fb PJ |
218 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']")); |
219 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']")); | |
220 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']")); | |
221 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']")); | |
6d2387a1 PJ |
222 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[6][text()='United States']")); |
223 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[7][text()='CA']")); | |
224 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[8][text()='Alameda']")); | |
6a488035 | 225 | |
89d6437d | 226 | // verify if the organization has been created -- CRM-15368 |
227 | $this->click("css=input#sort_name_navigation"); | |
228 | $this->type("css=input#sort_name_navigation", "$orgName"); | |
229 | $this->typeKeys("css=input#sort_name_navigation", "$orgName"); | |
230 | $this->waitForElementPresent("css=ul.ui-autocomplete li"); | |
231 | ||
232 | // visit contact summary page | |
233 | $this->click("css=ul.ui-autocomplete li"); | |
234 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
235 | ||
6a488035 | 236 | // Go back to Profile fields admin |
39a2888d | 237 | $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId", "xpath=//table/tbody/tr[1]/td[9]"); |
6a488035 TO |
238 | |
239 | // Edit first profile field | |
3379d026 | 240 | $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom', FALSE); |
6a488035 | 241 | |
39a2888d | 242 | $this->waitForElementPresent("visibility"); |
6a488035 TO |
243 | $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a"); |
244 | $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]"); | |
6c5f7368 | 245 | $this->waitForText('crm-notification-container', 'Is this field hidden from other users'); |
6a488035 TO |
246 | $this->select('visibility', 'value=Public Pages and Listings'); |
247 | } | |
96025800 | 248 | |
42daf119 | 249 | } |