commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / tests / phpunit / WebTest / Profile / SearchTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Profile_SearchTest
31 */
32 class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testSearchProfile() {
39 $this->webtestLogin();
40
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
46 // Add new profile.
47 $this->openCiviPage('admin/uf/group', 'reset=1');
48
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
57 $this->click('uf_group_type_Profile');
58 //click on save
59 $this->click('_qf_Group_next-bottom');
60 $this->waitForPageToLoad($this->getTimeoutMsec());
61 $this->waitForElementPresent("_qf_Field_next-bottom");
62
63 //check for profile create
64 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
65
66 // Get profile id (gid) from URL
67 $profileId = $this->urlArg('gid');
68
69 // Add Last Name field.
70 $this->waitForElementPresent("field_name[0]");
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');
82 //check for field add
83 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'.");
84
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 //check for field add
98 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'.");
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');
110 $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE);
111 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
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
124 $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE);
125 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
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', 'field_name[0]', FALSE);
138 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
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
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
160 // click on save
161 $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span[text()=' Use (create mode)']", FALSE);
162
163 $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href"));
164 $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_next');
165 $lastName = substr(sha1(rand()), 0, 7);
166 $orgName = 'Organisation' . substr(sha1(rand()), 0, 7);
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');
174
175 // fill country, state, county
176 $this->select('country-Primary', "United States");
177
178 // wait for state data to be populated
179 $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']");
180 $this->select('state_province-Primary', "California");
181
182 // wait for county data to be populated
183 $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']");
184 $this->select('county-Primary', "Alameda");
185
186 $this->type('current_employer', $orgName);
187
188 $this->clickLink('_qf_Edit_next', NULL);
189
190 $this->assertElementContainsText("css=span.msg-text", 'Your information has been saved.');
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");
201
202 // Fill state, county, country
203 $this->select('country-Primary', "United States");
204
205 // wait for state data to be populated
206 $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']");
207 $this->select('state_province-Primary', "California");
208
209 // wait for county data to be populated
210 $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']");
211 $this->select('county-Primary', "Alameda");
212
213 // Select Custom option
214 $this->select('custom_1', 'Education');
215 $this->clickLink('_qf_Search_refresh', NULL);
216
217 // Verify Data.
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']"));
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']"));
225
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
236 // Go back to Profile fields admin
237 $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId", "xpath=//table/tbody/tr[1]/td[9]");
238
239 // Edit first profile field
240 $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom', FALSE);
241
242 $this->waitForElementPresent("visibility");
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]");
245 $this->waitForText('crm-notification-container', 'Is this field hidden from other users');
246 $this->select('visibility', 'value=Public Pages and Listings');
247 }
248
249 }