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_Contact_SearchBuilderTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
6a488035 | 38 | function testSearchBuilderOptions() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
41 | $groupName = $this->WebtestAddGroup(); | |
42 | ||
43 | // Open the search builder | |
44 | $this->openCiviPage('contact/search/builder', 'reset=1'); | |
45 | ||
46 | $this->enterValues(1, 1, 'Contacts', 'Group(s)', NULL, '=', array($groupName)); | |
47 | $this->enterValues(1, 2, 'Contacts', 'Country', NULL, '=', array('United States')); | |
48 | $this->enterValues(1, 3, 'Individual', 'Gender', NULL, '=', array('Male')); | |
49 | $this->click('_qf_Builder_refresh'); | |
50 | $this->waitForPageToLoad(); | |
51 | ||
52 | // We should get no results. But check the options are all still set | |
53 | $this->waitForTextPresent('No matches found'); | |
54 | foreach (array($groupName, 'United States', 'Male') as $i => $label) { | |
55 | $this->waitForElementPresent("//span[@id='crm_search_value_1_$i']/select/option[2]"); | |
56 | $this->assertSelectedLabel("//span[@id='crm_search_value_1_$i']/select", $label); | |
57 | } | |
58 | } | |
59 | ||
60 | function testSearchBuilderRLIKE() { | |
61 | $this->webtestLogin(); | |
62 | ||
63 | // Adding contact | |
64 | // We're using Quick Add block on the main page for this. | |
65 | $firstName = substr(sha1(rand()), 0, 7); | |
66 | $this->createDetailContact($firstName); | |
67 | ||
68 | $sortName = "adv$firstName, $firstName"; | |
69 | $displayName = "$firstName adv$firstName"; | |
70 | ||
71 | $this->_searchBuilder("Postal Code", "100[0-9]", $sortName, "RLIKE"); | |
72 | } | |
73 | ||
74 | // function to create contact with details (contact details, address, Constituent information ...) | |
4cbe18b8 EM |
75 | /** |
76 | * @param null $firstName | |
77 | */ | |
6a488035 TO |
78 | function createDetailContact($firstName = NULL) { |
79 | ||
80 | if (!$firstName) { | |
81 | $firstName = substr(sha1(rand()), 0, 7); | |
82 | } | |
83 | ||
84 | // create contact type Individual with subtype | |
85 | // with most of values to required to search | |
86 | $Subtype = "Student"; | |
87 | $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => 'Individual'), '_qf_Contact_cancel'); | |
88 | ||
89 | // --- fill few values in Contact Detail block | |
90 | $this->type("first_name", "$firstName"); | |
91 | $this->type("middle_name", "mid$firstName"); | |
92 | $this->type("last_name", "adv$firstName"); | |
e6e201a5 | 93 | $this->select("contact_sub_type", "label=$Subtype"); |
6a488035 TO |
94 | $this->type("email_1_email", "$firstName@advsearch.co.in"); |
95 | $this->type("phone_1_phone", "123456789"); | |
96 | $this->type("external_identifier", "extid$firstName"); | |
97 | ||
98 | // --- fill few values in address | |
99 | $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]"); | |
100 | $this->waitForElementPresent("address_1_geo_code_2"); | |
101 | $this->type("address_1_street_address", "street 1 $firstName"); | |
102 | $this->type("address_1_supplemental_address_1", "street supplement 1 $firstName"); | |
103 | $this->type("address_1_supplemental_address_2", "street supplement 2 $firstName"); | |
104 | $this->type("address_1_city", "city$firstName"); | |
105 | $this->type("address_1_postal_code", "100100"); | |
106 | $this->select("address_1_country_id", "United States"); | |
107 | $this->select("address_1_state_province_id", "Alaska"); | |
108 | ||
109 | // save contact | |
110 | $this->click("_qf_Contact_upload_view"); | |
111 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
112 | $this->assertTrue($this->isTextPresent("$firstName adv$firstName")); | |
113 | } | |
114 | ||
13c415cc | 115 | function testSearchBuilderContacts() { |
6a488035 TO |
116 | $this->webtestLogin(); |
117 | ||
118 | //Individual | |
119 | $firstName = substr(sha1(rand()), 0, 7); | |
120 | $streetName = "street $firstName"; | |
121 | $sortName = "adv$firstName, $firstName"; | |
122 | $this->_createContact('Individual', $firstName, "$firstName@advsearch.co.in", $streetName); | |
123 | // search using search builder and advanced search | |
124 | $this->_searchBuilder('Street Address', $streetName, $sortName, '=', '1'); | |
125 | $this->_advancedSearch($streetName, $sortName, 'Individual', '1', 'street_address'); | |
126 | ||
127 | //Organization | |
13c415cc | 128 | $orgName = substr(sha1(rand()), 0, 7) . "org"; |
129 | $orgEmail = "ab" . rand() . "@{$orgName}.com"; | |
130 | $this->_createContact('Organization', $orgName, $orgEmail, "street $orgName"); | |
6a488035 | 131 | // search using search builder and advanced search |
13c415cc | 132 | $this->_searchBuilder('Email', $orgEmail, $orgName, '=', '1'); |
133 | $this->_advancedSearch($orgEmail, $orgName, 'Organization', '1', 'email'); | |
6a488035 TO |
134 | |
135 | //Household | |
13c415cc | 136 | $householdName = "household" . substr(sha1(rand()), 0, 7); |
137 | $householdEmail = "h1" . rand() . "@{$householdName}.com"; | |
138 | $this->_createContact('Household', $householdName, $householdEmail, "street $householdName"); | |
6a488035 | 139 | // search using search builder and advanced search |
13c415cc | 140 | $this->_searchBuilder('Email', $householdEmail, $householdName, '=', '1'); |
141 | $this->_advancedSearch($householdEmail, $householdName, 'Household', '1', 'email'); | |
6a488035 | 142 | |
289c8051 | 143 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 TO |
144 | |
145 | // searching contacts whose email is not set | |
13c415cc | 146 | $firstName1 = "00a1" . substr(sha1(rand()), 0, 7); |
6a488035 TO |
147 | $this->type("first_name", $firstName1); |
148 | $this->type("last_name", "01adv$firstName1"); | |
149 | // save contact | |
150 | $this->click("_qf_Contact_upload_view"); | |
151 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
289c8051 | 152 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 | 153 | |
13c415cc | 154 | $firstName2 = "00a2" . substr(sha1(rand()), 0, 7); |
6a488035 TO |
155 | $this->type("first_name", $firstName2); |
156 | $this->type("last_name", "02adv$firstName2"); | |
157 | // save contact | |
158 | $this->click("_qf_Contact_upload_view"); | |
159 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
289c8051 | 160 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 | 161 | |
13c415cc | 162 | $firstName3 = "00a3" . substr(sha1(rand()), 0, 7); |
6a488035 TO |
163 | $this->type("first_name", $firstName3); |
164 | $this->type("last_name", "03adv$firstName3"); | |
165 | // save contact | |
166 | $this->click("_qf_Contact_upload_view"); | |
167 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
13c415cc | 168 | $this->_searchBuilder('Email', NULL, NULL, 'IS NULL'); |
b5e4fcd9 | 169 | $this->type("xpath=//*[@id='Builder-rows-per-page-select']", '100'); |
170 | $this->waitForElementPresent("xpath=//*[@id='Builder-rows-per-page-select']"); | |
13c415cc | 171 | $names = array( |
172 | 1 => $firstName1, | |
173 | 2 => $firstName2, | |
174 | 3 => $firstName3, | |
175 | ); | |
176 | foreach ($names as $key => $value) { | |
6a488035 TO |
177 | $this->assertTrue($this->isTextPresent($value)); |
178 | } | |
179 | //searching contacts whose phone field is empty | |
13c415cc | 180 | $this->_searchBuilder('Phone', NULL, NULL, 'IS EMPTY'); |
181 | foreach ($names as $key => $value) { | |
6a488035 TO |
182 | $this->assertTrue($this->isTextPresent($value)); |
183 | } | |
184 | //searching contacts whose phone field is not empty | |
13c415cc | 185 | $this->_searchBuilder('Phone', NULL, $firstName, 'IS NOT EMPTY'); |
b5e4fcd9 | 186 | $this->type("xpath=//*[@id='Builder-rows-per-page-select']", '100'); |
187 | $this->waitForElementPresent("xpath=//*[@id='Builder-rows-per-page-select']"); | |
6a488035 TO |
188 | $this->assertTrue($this->isTextPresent($firstName)); |
189 | ||
13c415cc | 190 | $firstName4 = "AB" . substr(sha1(rand()), 0, 7); |
6a488035 | 191 | $postalCode = rand(); |
13c415cc | 192 | $this->_createContact('Individual', $firstName4, "$firstName4@advsearch.co.in", NULL, $postalCode); |
193 | $firstName5 = "CD" . substr(sha1(rand()), 0, 7); | |
194 | $this->_createContact('Individual', $firstName5, "$firstName5@advsearch.co.in", NULL, $postalCode); | |
195 | $firstName6 = "EF" . substr(sha1(rand()), 0, 7); | |
196 | $this->_createContact('Organization', $firstName6, "$firstName6@advsearch.co.in", NULL, $postalCode); | |
197 | $firstName7 = "GH" . substr(sha1(rand()), 0, 7); | |
198 | $this->_createContact('Household', $firstName7, "$firstName7@advsearch.co.in", NULL, $postalCode); | |
6a488035 TO |
199 | |
200 | // check if the resultset of search builder and advanced search match for the postal code | |
13c415cc | 201 | $this->_searchBuilder('Postal Code', $postalCode, NULL, 'LIKE', '4'); |
202 | $this->_advancedSearch($postalCode, NULL, NULL, '4', 'postal_code'); | |
6a488035 | 203 | |
13c415cc | 204 | $firstName8 = "abcc" . substr(sha1(rand()), 0, 7); |
205 | $this->_createContact('Individual', $firstName8, "$firstName8@advsearch.co.in", NULL); | |
6a488035 TO |
206 | $this->_searchBuilder('Note(s): Body and Subject', "this is notes by $firstName8", $firstName8, 'LIKE'); |
207 | $this->_searchBuilder('Note(s): Subject only', "this is subject by $firstName8", $firstName8, 'LIKE'); | |
208 | $this->_searchBuilder('Note(s): Body only', "this is notes by $firstName8", $firstName8, 'LIKE'); | |
13c415cc | 209 | $this->_advancedSearch("this is notes by $firstName8", $firstName8, NULL, NULL, 'note_body', 'notes'); |
210 | $this->_advancedSearch("this is subject by $firstName8", $firstName8, NULL, NULL, 'note_subject', 'notes'); | |
211 | $this->_advancedSearch("this is notes by $firstName8", $firstName8, NULL, NULL, 'note_both', 'notes'); | |
4121e1c2 | 212 | $this->_advancedSearch("this is notes by $firstName8", $firstName8, NULL, NULL, 'note_both', 'notes'); |
6a488035 TO |
213 | } |
214 | ||
4cbe18b8 EM |
215 | /** |
216 | * @param $field | |
217 | * @param null $fieldValue | |
218 | * @param null $name | |
219 | * @param string $op | |
220 | * @param null $count | |
221 | */ | |
6a488035 TO |
222 | function _searchBuilder($field, $fieldValue = NULL, $name = NULL, $op = '=', $count = NULL) { |
223 | // search builder using contacts(not using contactType) | |
289c8051 | 224 | $this->openCiviPage("contact/search/builder", "reset=1"); |
6a488035 TO |
225 | $this->enterValues(1, 1, 'Contacts', $field, NULL, $op, "$fieldValue"); |
226 | $this->click("id=_qf_Builder_refresh"); | |
227 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
228 | if (($op == '=' || $op == 'LIKE') && $fieldValue) { | |
229 | $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$fieldValue"); | |
230 | } | |
231 | if ($name) { | |
232 | $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$name"); | |
233 | } | |
234 | if ($count) { | |
235 | $this->assertElementContainsText('search-status', "$count Contact"); | |
236 | } | |
237 | } | |
238 | ||
239 | /** | |
240 | * Enter form values in a Search Builder row | |
241 | */ | |
242 | function enterValues($set, $row, $entity, $field, $loc, $op, $value = '') { | |
243 | if ($set > 1 && $row == 1) { | |
244 | $this->click('addBlock'); | |
245 | } | |
246 | if ($row > 1) { | |
247 | $this->click("addMore_{$set}"); | |
248 | } | |
249 | // In the DOM rows are 0 indexed and sets are 1 indexed, so normalizing | |
250 | $row--; | |
251 | ||
252 | $this->waitForElementPresent("mapper_{$set}_{$row}_0"); | |
253 | $this->select("mapper_{$set}_{$row}_0", "label=$entity"); | |
254 | $this->select("mapper_{$set}_{$row}_1", "label=$field"); | |
255 | if ($loc) { | |
256 | $this->select("mapper_{$set}_{$row}_2", "label=$loc"); | |
257 | } | |
de02cccc | 258 | $this->select("operator_{$set}_{$row}", "value=$op"); |
6a488035 TO |
259 | if (is_array($value)) { |
260 | $this->waitForElementPresent("css=#crm_search_value_{$set}_{$row} select option + option"); | |
261 | foreach ($value as $val) { | |
289c8051 | 262 | if ($op != 'IN') { |
76e86fd8 CW |
263 | $select = 'select'; |
264 | ||
289c8051 PN |
265 | } |
266 | else { | |
76e86fd8 CW |
267 | $select = 'addSelection'; |
268 | ||
289c8051 PN |
269 | } |
270 | $this->$select("css=#crm_search_value_{$set}_{$row} select", "label=$val"); | |
6a488035 TO |
271 | } |
272 | } | |
273 | elseif ($value && substr($value, 0, 5) == 'date:') { | |
274 | $this->webtestFillDate("value_{$set}_{$row}", trim(substr($value, 5))); | |
275 | } | |
276 | elseif ($value) { | |
277 | $this->type("value_{$set}_{$row}", $value); | |
278 | } | |
279 | } | |
280 | ||
4cbe18b8 EM |
281 | /** |
282 | * @param null $fieldValue | |
283 | * @param null $name | |
284 | * @param null $contactType | |
285 | * @param null $count | |
286 | * @param $field | |
287 | */ | |
13c415cc | 288 | function _advancedSearch($fieldValue = NULL, $name = NULL, $contactType = NULL, $count = NULL, $field) { |
6a488035 | 289 | //advanced search by selecting the contactType |
289c8051 | 290 | $this->openCiviPage("contact/search/advanced", "reset=1"); |
13c415cc | 291 | if (isset($contactType)) { |
c1d1bf14 | 292 | $this->select("id=contact_type", "value=$contactType"); |
6a488035 TO |
293 | } |
294 | if (substr($field, 0, 5) == 'note_') { | |
295 | $this->click("notes"); | |
296 | $this->waitForElementPresent("xpath=//div[@id='notes-search']/table/tbody/tr/td[2]/input[3]"); | |
297 | if ($field == 'note_body') { | |
298 | $this->click("CIVICRM_QFID_2_note_option"); | |
299 | } | |
300 | elseif ($field == 'note_subject') { | |
301 | $this->click("CIVICRM_QFID_3_note_option"); | |
302 | } | |
303 | else { | |
304 | $this->click("CIVICRM_QFID_6_note_option"); | |
305 | } | |
13c415cc | 306 | $this->type("note", $fieldValue); |
6a488035 TO |
307 | } |
308 | else { | |
309 | $this->click("location"); | |
310 | $this->waitForElementPresent("xpath=//div[@id='location']/table/tbody/tr[2]/td/table/tbody/tr[4]/td[2]/select"); | |
311 | if ($contactType == 'Individual') { | |
13c415cc | 312 | $this->type("$field", $fieldValue); |
6a488035 TO |
313 | } |
314 | else { | |
13c415cc | 315 | $this->type("$field", $fieldValue); |
6a488035 TO |
316 | } |
317 | } | |
318 | $this->click("_qf_Advanced_refresh"); | |
319 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
320 | ||
321 | //the search result should be same as the one that we got in search builder | |
322 | if ($fieldValue) { | |
323 | $this->assertElementContainsText('Advanced', "$fieldValue"); | |
324 | } | |
325 | if ($name) { | |
326 | $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$name"); | |
327 | } | |
328 | if ($count) { | |
329 | $this->assertElementContainsText('search-status', "$count Contact"); | |
330 | } | |
331 | } | |
332 | ||
4cbe18b8 EM |
333 | /** |
334 | * @param $contactType | |
335 | * @param $name | |
336 | * @param $email | |
337 | * @param null $streetName | |
338 | * @param null $postalCode | |
339 | */ | |
13c415cc | 340 | function _createContact($contactType, $name, $email, $streetName = NULL, $postalCode = NULL) { |
6a488035 TO |
341 | $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => $contactType), '_qf_Contact_cancel'); |
342 | ||
13c415cc | 343 | if ($contactType == 'Individual') { |
6a488035 TO |
344 | $this->type("first_name", "$name"); |
345 | $this->type("last_name", "adv$name"); | |
346 | $name = "$name adv$name"; | |
13c415cc | 347 | } |
348 | elseif ($contactType == 'Organization') { | |
349 | $this->type("organization_name", $name); | |
350 | } | |
351 | else { | |
352 | $this->type("household_name", $name); | |
6a488035 TO |
353 | } |
354 | $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]"); | |
355 | $this->waitForElementPresent("address_1_geo_code_2"); | |
13c415cc | 356 | $this->type("email_1_email", $email); |
357 | $this->type("phone_1_phone", "9876543210"); | |
6a488035 TO |
358 | $this->type("address_1_street_address", $streetName); |
359 | $this->select("address_1_country_id", "United States"); | |
360 | $this->select("address_1_state_province_id", "Alaska"); | |
13c415cc | 361 | $this->type("address_1_postal_code", $postalCode); |
6a488035 TO |
362 | |
363 | $this->click("//form[@id='Contact']/div[2]/div[6]/div[1]"); | |
364 | $this->waitForElementPresent("note"); | |
365 | $this->type("subject", "this is subject by $name"); | |
366 | $this->type("note", "this is notes by $name"); | |
367 | ||
368 | // save contact | |
369 | $this->click("_qf_Contact_upload_view"); | |
370 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
371 | $this->assertTrue($this->isTextPresent("$name has been created.")); | |
372 | } | |
289c8051 PN |
373 | |
374 | /* | |
375 | * Webtest for CRM-12148 | |
376 | * | |
377 | */ | |
378 | function testSearchBuilderfinancialType() { | |
379 | // Logging in. Remember to wait for page to load. In most cases, | |
380 | // you can rely on 30000 as the value that allows your test to pass, however, | |
381 | // sometimes your test might fail because of this. In such cases, it's better to pick one element | |
382 | // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole | |
383 | // page contents loaded and you can continue your test execution. | |
384 | $this->webtestLogin(); | |
76e86fd8 | 385 | |
289c8051 PN |
386 | // add financial type |
387 | $financialTypeName1 = 'Financial Type' . substr(sha1(rand()), 0, 5);; | |
388 | $financialTypeName2 = 'Financial Type' . substr(sha1(rand()), 0, 5);; | |
389 | $financialType = array( | |
390 | 'name' => $financialTypeName1, | |
391 | 'is_reserved' => FALSE, | |
392 | 'is_deductible' => FALSE, | |
393 | ); | |
394 | $this->addeditFinancialType($financialType); | |
289c8051 PN |
395 | $financialType['name'] = $financialTypeName2; |
396 | $this->addeditFinancialType($financialType); | |
289c8051 PN |
397 | //create 6 contribution |
398 | $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", "_qf_Contribution_upload"); | |
399 | for ($i = 1; $i <= 6; $i++) { | |
400 | if ($i % 2 == 0) { | |
401 | $financialType = $financialTypeName1; | |
402 | } | |
403 | else { | |
404 | $financialType = $financialTypeName2; | |
405 | } | |
406 | // create new contact using dialog | |
407 | $firstName = substr(sha1(rand()), 0, 7); | |
408 | $this->webtestNewDialogContact($firstName, 'Contributor', $firstName . '@example.com'); | |
409 | $this->select('financial_type_id', $financialType); | |
410 | $this->type('total_amount', 100 * $i); | |
225a8648 | 411 | $this->clickLink('_qf_Contribution_upload_new', '_qf_Contribution_upload_new'); |
289c8051 PN |
412 | } |
413 | $this->openCiviPage("contact/search/builder", "reset=1", "_qf_Builder_refresh"); | |
76e86fd8 | 414 | |
289c8051 PN |
415 | $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName1)); |
416 | $this->click('_qf_Builder_refresh'); | |
417 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
76e86fd8 | 418 | |
289c8051 | 419 | $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts'); |
76e86fd8 | 420 | |
289c8051 PN |
421 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); |
422 | $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName2)); | |
423 | $this->click('_qf_Builder_refresh'); | |
424 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
425 | $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts'); | |
76e86fd8 | 426 | |
289c8051 | 427 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); |
13c415cc | 428 | $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, 'IN', array( |
429 | $financialTypeName1, | |
430 | $financialTypeName2 | |
431 | )); | |
289c8051 PN |
432 | $this->click('_qf_Builder_refresh'); |
433 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
434 | $this->assertTrue($this->isTextPresent('6 Contacts'), 'Missing text: ' . '6 Contacts'); | |
435 | } | |
3c53f77e DL |
436 | |
437 | /* | |
438 | * Webtest for CRM-12588 | |
439 | * | |
440 | */ | |
441 | function testSearchBuilderMembershipType() { | |
442 | $this->webtestLogin(); | |
443 | ||
444 | // create first contact | |
445 | $firstName1 = substr(sha1(rand()), 0, 7); | |
446 | $this->webtestAddContact($firstName1, "Memberson", "Memberson{$firstName1}@memberson.name"); | |
447 | $contactName1 = "Memberson, $firstName1"; | |
448 | ||
449 | // create Second contact | |
450 | $firstName2 = substr(sha1(rand()), 0, 7); | |
451 | $this->webtestAddContact($firstName2, "Memberson", "Memberson{$firstName2}@memberson.name"); | |
452 | $contactName2 = "Memberson, $firstName2"; | |
453 | ||
454 | // add membership type | |
455 | $membershipTypes = $this->webtestAddMembershipType(); | |
456 | ||
457 | // now add membership | |
458 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); | |
459 | ||
460 | // select contact | |
461 | $this->webtestFillAutocomplete($firstName1); | |
462 | ||
463 | // fill in Membership Organization | |
464 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
465 | ||
466 | // select membership type | |
467 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
468 | ||
469 | // fill in Source | |
470 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
471 | ||
472 | // fill in Start Date | |
473 | $this->webtestFillDate('start_date'); | |
474 | ||
475 | // Clicking save. | |
476 | $this->clickLink("_qf_Membership_upload"); | |
477 | ||
478 | // page was loaded | |
479 | $this->waitForTextPresent("Membership StandaloneAddTest Webtest"); | |
480 | ||
481 | // now add membership for second contact | |
482 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); | |
483 | $this->webtestFillAutocomplete($firstName2); | |
484 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
485 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
486 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
487 | $this->webtestFillDate('start_date'); | |
488 | ||
489 | // fill in Status Override? | |
490 | $this->click("is_override"); | |
491 | $this->waitForElementPresent("status_id"); | |
492 | $this->select("status_id", "label=Grace"); | |
493 | ||
494 | // Clicking save. | |
495 | $this->clickLink("_qf_Membership_upload"); | |
496 | $this->waitForTextPresent("Membership StandaloneAddTest Webtest"); | |
497 | ||
498 | // Open the search builder | |
499 | $this->openCiviPage('contact/search/builder', 'reset=1'); | |
500 | $this->enterValues(1, 1, 'Membership', 'Membership Type', NULL, '=', array($membershipTypes['membership_type'])); | |
501 | ||
502 | $this->clickLink('_qf_Builder_refresh'); | |
503 | $this->waitForText('search-status', "2 Contacts"); | |
504 | ||
505 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); | |
506 | $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, '=', array('New')); | |
507 | $this->clickLink('_qf_Builder_refresh'); | |
508 | $this->waitForText('search-status', "1 Contact"); | |
509 | ||
02667514 | 510 | $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, '=', array('Grace')); |
3c53f77e DL |
511 | $this->clickLink('_qf_Builder_refresh'); |
512 | $this->waitForText('search-status', "1 Contact"); | |
513 | ||
514 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); | |
515 | $this->click("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a"); | |
13c415cc | 516 | $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, 'IN', array('New', 'Grace')); |
3c53f77e DL |
517 | $this->clickLink('_qf_Builder_refresh'); |
518 | $this->waitForText('search-status', "2 Contacts"); | |
519 | ||
520 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); | |
521 | $this->click("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a"); | |
13c415cc | 522 | $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, 'IN', array('Current', 'Expired')); |
3c53f77e DL |
523 | $this->clickLink('_qf_Builder_refresh'); |
524 | $this->waitForText("xpath=//form[@id='Builder']/div[3]/div/div", "No matches found for"); | |
525 | ||
526 | // Find Membership | |
527 | $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh"); | |
528 | $this->click("xpath=//label[text()='{$membershipTypes['membership_type']}']"); | |
529 | $this->clickLink('_qf_Search_refresh'); | |
530 | $this->waitForText('search-status', "2 Results"); | |
531 | ||
532 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); | |
533 | $this->click("xpath=//label[text()='New']"); | |
534 | $this->click("xpath=//label[text()='Grace']"); | |
535 | $this->clickLink('_qf_Search_refresh'); | |
536 | $this->waitForText('search-status', "2 Results"); | |
537 | ||
538 | $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); | |
539 | $this->click("xpath=//label[text()='New']"); | |
540 | $this->clickLink('_qf_Search_refresh'); | |
541 | $this->waitForText('search-status', "1 Result"); | |
542 | } | |
543 | ||
6a488035 | 544 | } |