Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
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 | ||
38 | 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()); | |
61 | ||
62 | //check for profile create | |
6c5f7368 | 63 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); |
6a488035 TO |
64 | |
65 | // Get profile id (gid) from URL | |
a471a3b6 | 66 | $profileId = $this->urlArg('gid'); |
6a488035 TO |
67 | |
68 | // Add Last Name field. | |
69 | $this->click('field_name[0]'); | |
70 | $this->select('field_name[0]', 'value=Individual'); | |
71 | $this->click('field_name[1]'); | |
72 | $this->select('field_name[1]', 'value=last_name'); | |
73 | $this->click("//option[@value='Individual']"); | |
74 | $this->click('visibility'); | |
75 | $this->select('visibility', 'value=Public Pages'); | |
76 | $this->click('is_searchable'); | |
77 | $this->click('in_selector'); | |
78 | // click on save | |
79 | $this->click('_qf_Field_next_new-bottom'); | |
80 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
81 | //check for field add | |
6c5f7368 CW |
82 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'."); |
83 | $this->waitForText('crm-notification-container', 'You can add another profile field.'); | |
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'); | |
97 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
98 | //check for field add | |
6c5f7368 CW |
99 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'."); |
100 | $this->waitForText('crm-notification-container', 'You can add another profile field.'); | |
6a488035 TO |
101 | |
102 | // Add Sample Custom Field. | |
103 | $this->click('field_name[0]'); | |
104 | $this->select('field_name[0]', 'value=Individual'); | |
105 | $this->click('field_name[1]'); | |
106 | $this->select('field_name[1]', 'value=custom_1'); | |
107 | $this->click("//option[@value='Individual']"); | |
108 | $this->click('visibility'); | |
109 | $this->select('visibility', 'value=Public Pages'); | |
110 | $this->click('is_searchable'); | |
111 | $this->click('in_selector'); | |
6d2387a1 PJ |
112 | $this->clickLink('_qf_Field_next_new-bottom'); |
113 | ||
114 | // Add state, country and county field | |
115 | $this->click('field_name[0]'); | |
116 | $this->select('field_name[0]', 'value=Contact'); | |
117 | $this->click('field_name[1]'); | |
118 | $this->select('field_name[1]', 'value=country'); | |
119 | $this->select('field_name[2]', 'Primary'); | |
120 | $this->click('visibility'); | |
121 | $this->select('visibility', 'value=Public Pages and Listings'); | |
122 | $this->click('is_searchable'); | |
123 | $this->click('in_selector'); | |
124 | // click on save and new | |
125 | $this->clickLink('_qf_Field_next_new-bottom'); | |
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 | |
137 | $this->clickLink('_qf_Field_next_new-bottom'); | |
138 | ||
139 | $this->click('field_name[0]'); | |
140 | $this->select('field_name[0]', 'value=Contact'); | |
141 | $this->click('field_name[1]'); | |
142 | $this->select('field_name[1]', 'value=county'); | |
143 | $this->select('field_name[2]', 'Primary'); | |
144 | $this->click('visibility'); | |
145 | $this->select('visibility', 'value=Public Pages and Listings'); | |
146 | $this->click('is_searchable'); | |
147 | $this->click('in_selector'); | |
148 | ||
6a488035 | 149 | // click on save |
225a8648 | 150 | $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span[text()='Use (create mode)']"); |
6a488035 | 151 | |
3379d026 | 152 | $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href")); |
153 | $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_cancel'); | |
6a488035 TO |
154 | $this->waitForElementPresent('_qf_Edit_next'); |
155 | $lastName = substr(sha1(rand()), 0, 7); | |
156 | ||
157 | // Fill Last Name | |
158 | $this->type('last_name', $lastName); | |
159 | // Fill Email | |
160 | $this->type('email-Primary', "jhon@$lastName.com"); | |
161 | // Select Custom option | |
162 | $this->click('CIVICRM_QFID_Edu_2'); | |
6d2387a1 PJ |
163 | |
164 | // fill country, state, county | |
165 | $this->select('country-Primary', "United States"); | |
166 | // adding sleep gives time for state data | |
167 | // to get populated in state combo box | |
168 | sleep(1); | |
169 | $this->select('state_province-Primary', "California"); | |
170 | // adding sleep gives time for county data | |
171 | // to get populated in county combo box | |
172 | sleep(1); | |
173 | $this->select('county-Primary', "Alameda"); | |
6a488035 | 174 | $this->click('_qf_Edit_next'); |
305515fb PJ |
175 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
176 | ||
3379d026 | 177 | $this->assertElementContainsText("css=span.msg-text", 'Your information has been saved.'); |
6a488035 TO |
178 | |
179 | // Search Contact via profile. | |
180 | $this->waitForElementPresent("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']"); | |
181 | $this->click("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']"); | |
182 | $this->waitForElementPresent("xpath=//div[@class='crm-block crm-form-block']"); | |
183 | $this->click("xpath=//div[@class='crm-block crm-form-block']"); | |
184 | // Fill Last Name | |
185 | $this->type('last_name', $lastName); | |
186 | // Fill Email | |
187 | $this->type('email-Primary', "jhon@$lastName.com"); | |
6d2387a1 PJ |
188 | |
189 | // Fill state, county, country | |
190 | $this->select('country-Primary', "United States"); | |
191 | // adding sleep gives time for state data | |
192 | // to get populated in state combo box | |
193 | sleep(1); | |
194 | $this->select('state_province-Primary', "California"); | |
195 | // adding sleep gives time for county data | |
196 | // to get populated in county combo box | |
197 | sleep(1); | |
198 | $this->select('county-Primary', "Alameda"); | |
199 | ||
6a488035 TO |
200 | // Select Custom option |
201 | $this->click('CIVICRM_QFID_Edu_2'); | |
202 | $this->click('_qf_Search_refresh'); | |
305515fb | 203 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
204 | |
205 | // Verify Data. | |
305515fb PJ |
206 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']")); |
207 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']")); | |
208 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']")); | |
209 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']")); | |
6d2387a1 PJ |
210 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[6][text()='United States']")); |
211 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[7][text()='CA']")); | |
212 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[8][text()='Alameda']")); | |
6a488035 TO |
213 | |
214 | // Go back to Profile fields admin | |
305515fb | 215 | $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId"); |
6a488035 TO |
216 | |
217 | // Edit first profile field | |
218 | $this->waitForElementPresent("xpath=//table/tbody/tr[1]/td[9]"); | |
3379d026 | 219 | $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom', FALSE); |
6a488035 TO |
220 | |
221 | // sleep 5 to make sure jQuery is not hiding field after page load | |
efb29358 CW |
222 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
223 | // Sleep should never be used for wait for anything to load from the server | |
224 | // Justification for this instance: FIXME | |
6a488035 TO |
225 | sleep(5); |
226 | $this->assertTrue($this->isElementPresent("visibility"), 'Visibility field not present when editing existing profile field.'); | |
227 | $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a"); | |
228 | $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]"); | |
6c5f7368 | 229 | $this->waitForText('crm-notification-container', 'Is this field hidden from other users'); |
6a488035 TO |
230 | $this->select('visibility', 'value=Public Pages and Listings'); |
231 | } | |
42daf119 | 232 | } |