Merge pull request #8613 from monishdeb/CRM-18989
[civicrm-core.git] / tests / phpunit / WebTest / Contact / SearchBuilderTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
81621fee 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
fa938177 6 | Copyright CiviCRM LLC (c) 2004-2016 |
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 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Contact_SearchBuilderTest
31 */
6a488035
TO
32class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
00be9182 38 public 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));
86797006 47 $this->enterValues(1, 2, 'Contacts', 'Country', NULL, '=', array('UNITED STATES'));
6a488035
TO
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
64b211dd 53 $this->waitForTextPresent('No matches found for:');
86797006 54 foreach (array($groupName, 'UNITED STATES', 'Male') as $i => $label) {
6a488035
TO
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
00be9182 60 public function testSearchBuilderRLIKE() {
6a488035
TO
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
d79be26c 71 $this->_searchBuilder("Postal Code", "100[0-9]", $sortName, "RLIKE");
6a488035
TO
72 }
73
4cbe18b8 74 /**
4f1f1f2a 75 * function to create contact with details (contact details, address, Constituent information ...)
4cbe18b8
EM
76 * @param null $firstName
77 */
00be9182 78 public function createDetailContact($firstName = NULL) {
6a488035
TO
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");
86797006 106 $this->select("address_1_country_id", "UNITED STATES");
6a488035
TO
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
00be9182 115 public 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');
13c415cc 169 $names = array(
170 1 => $firstName1,
171 2 => $firstName2,
172 3 => $firstName3,
173 );
174 foreach ($names as $key => $value) {
6a488035
TO
175 $this->assertTrue($this->isTextPresent($value));
176 }
177 //searching contacts whose phone field is empty
13c415cc 178 $this->_searchBuilder('Phone', NULL, NULL, 'IS EMPTY');
179 foreach ($names as $key => $value) {
6a488035
TO
180 $this->assertTrue($this->isTextPresent($value));
181 }
182 //searching contacts whose phone field is not empty
13c415cc 183 $this->_searchBuilder('Phone', NULL, $firstName, 'IS NOT EMPTY');
6a488035
TO
184 $this->assertTrue($this->isTextPresent($firstName));
185
13c415cc 186 $firstName4 = "AB" . substr(sha1(rand()), 0, 7);
6a488035 187 $postalCode = rand();
13c415cc 188 $this->_createContact('Individual', $firstName4, "$firstName4@advsearch.co.in", NULL, $postalCode);
189 $firstName5 = "CD" . substr(sha1(rand()), 0, 7);
190 $this->_createContact('Individual', $firstName5, "$firstName5@advsearch.co.in", NULL, $postalCode);
191 $firstName6 = "EF" . substr(sha1(rand()), 0, 7);
192 $this->_createContact('Organization', $firstName6, "$firstName6@advsearch.co.in", NULL, $postalCode);
193 $firstName7 = "GH" . substr(sha1(rand()), 0, 7);
194 $this->_createContact('Household', $firstName7, "$firstName7@advsearch.co.in", NULL, $postalCode);
6a488035
TO
195
196 // check if the resultset of search builder and advanced search match for the postal code
d79be26c 197 $this->_searchBuilder('Postal Code', $postalCode, NULL, 'LIKE', '4');
13c415cc 198 $this->_advancedSearch($postalCode, NULL, NULL, '4', 'postal_code');
6a488035 199
13c415cc 200 $firstName8 = "abcc" . substr(sha1(rand()), 0, 7);
201 $this->_createContact('Individual', $firstName8, "$firstName8@advsearch.co.in", NULL);
d97b92de
SB
202 $this->_searchBuilder('Note(s): Body and Subject', "this is notes by $firstName8 adv$firstName8", $firstName8, 'LIKE');
203 $this->_searchBuilder('Note(s): Subject Only', "this is subject by $firstName8 adv$firstName8", $firstName8, 'LIKE');
204 $this->_searchBuilder('Note(s): Body Only', "this is notes by $firstName8 adv$firstName8", $firstName8, 'LIKE');
205 $this->_advancedSearch("this is notes by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_body', 'notes');
206 $this->_advancedSearch("this is subject by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_subject', 'notes');
207 $this->_advancedSearch("this is notes by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_both', 'notes');
208 $this->_advancedSearch("this is notes by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_both', 'notes');
6a488035
TO
209 }
210
4cbe18b8
EM
211 /**
212 * @param $field
213 * @param null $fieldValue
214 * @param null $name
215 * @param string $op
216 * @param null $count
217 */
00be9182 218 public function _searchBuilder($field, $fieldValue = NULL, $name = NULL, $op = '=', $count = NULL) {
6a488035 219 // search builder using contacts(not using contactType)
289c8051 220 $this->openCiviPage("contact/search/builder", "reset=1");
6a488035
TO
221 $this->enterValues(1, 1, 'Contacts', $field, NULL, $op, "$fieldValue");
222 $this->click("id=_qf_Builder_refresh");
223 $this->waitForPageToLoad($this->getTimeoutMsec());
224 if (($op == '=' || $op == 'LIKE') && $fieldValue) {
225 $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$fieldValue");
226 }
227 if ($name) {
228 $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$name");
229 }
230 if ($count) {
231 $this->assertElementContainsText('search-status', "$count Contact");
232 }
233 }
234
235 /**
eceb18cc 236 * Enter form values in a Search Builder row.
1e1fdcf6
EM
237 * @param $set
238 * @param $row
239 * @param $entity
240 * @param $field
241 * @param $loc
242 * @param $op
243 * @param string $value
6a488035 244 */
00be9182 245 public function enterValues($set, $row, $entity, $field, $loc, $op, $value = '') {
6a488035
TO
246 if ($set > 1 && $row == 1) {
247 $this->click('addBlock');
248 }
249 if ($row > 1) {
250 $this->click("addMore_{$set}");
251 }
252 // In the DOM rows are 0 indexed and sets are 1 indexed, so normalizing
253 $row--;
254
255 $this->waitForElementPresent("mapper_{$set}_{$row}_0");
256 $this->select("mapper_{$set}_{$row}_0", "label=$entity");
257 $this->select("mapper_{$set}_{$row}_1", "label=$field");
258 if ($loc) {
259 $this->select("mapper_{$set}_{$row}_2", "label=$loc");
260 }
de02cccc 261 $this->select("operator_{$set}_{$row}", "value=$op");
6a488035
TO
262 if (is_array($value)) {
263 $this->waitForElementPresent("css=#crm_search_value_{$set}_{$row} select option + option");
264 foreach ($value as $val) {
289c8051 265 if ($op != 'IN') {
76e86fd8
CW
266 $select = 'select';
267
289c8051
PN
268 }
269 else {
76e86fd8
CW
270 $select = 'addSelection';
271
289c8051
PN
272 }
273 $this->$select("css=#crm_search_value_{$set}_{$row} select", "label=$val");
6a488035
TO
274 }
275 }
276 elseif ($value && substr($value, 0, 5) == 'date:') {
277 $this->webtestFillDate("value_{$set}_{$row}", trim(substr($value, 5)));
278 }
279 elseif ($value) {
280 $this->type("value_{$set}_{$row}", $value);
281 }
282 }
283
4cbe18b8
EM
284 /**
285 * @param null $fieldValue
286 * @param null $name
287 * @param null $contactType
288 * @param null $count
289 * @param $field
290 */
00be9182 291 public function _advancedSearch($fieldValue = NULL, $name = NULL, $contactType = NULL, $count = NULL, $field) {
6a488035 292 //advanced search by selecting the contactType
289c8051 293 $this->openCiviPage("contact/search/advanced", "reset=1");
13c415cc 294 if (isset($contactType)) {
c1d1bf14 295 $this->select("id=contact_type", "value=$contactType");
6a488035
TO
296 }
297 if (substr($field, 0, 5) == 'note_') {
298 $this->click("notes");
299 $this->waitForElementPresent("xpath=//div[@id='notes-search']/table/tbody/tr/td[2]/input[3]");
300 if ($field == 'note_body') {
301 $this->click("CIVICRM_QFID_2_note_option");
302 }
303 elseif ($field == 'note_subject') {
304 $this->click("CIVICRM_QFID_3_note_option");
305 }
306 else {
307 $this->click("CIVICRM_QFID_6_note_option");
308 }
13c415cc 309 $this->type("note", $fieldValue);
6a488035
TO
310 }
311 else {
312 $this->click("location");
60f44e0c 313 $this->waitForElementPresent("$field");
6a488035 314 if ($contactType == 'Individual') {
13c415cc 315 $this->type("$field", $fieldValue);
6a488035
TO
316 }
317 else {
13c415cc 318 $this->type("$field", $fieldValue);
6a488035
TO
319 }
320 }
321 $this->click("_qf_Advanced_refresh");
322 $this->waitForPageToLoad($this->getTimeoutMsec());
323
324 //the search result should be same as the one that we got in search builder
325 if ($fieldValue) {
326 $this->assertElementContainsText('Advanced', "$fieldValue");
327 }
328 if ($name) {
329 $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$name");
330 }
331 if ($count) {
332 $this->assertElementContainsText('search-status', "$count Contact");
333 }
334 }
335
4cbe18b8
EM
336 /**
337 * @param $contactType
100fef9d 338 * @param string $name
4cbe18b8
EM
339 * @param $email
340 * @param null $streetName
341 * @param null $postalCode
342 */
00be9182 343 public function _createContact($contactType, $name, $email, $streetName = NULL, $postalCode = NULL) {
6a488035
TO
344 $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => $contactType), '_qf_Contact_cancel');
345
13c415cc 346 if ($contactType == 'Individual') {
6a488035
TO
347 $this->type("first_name", "$name");
348 $this->type("last_name", "adv$name");
349 $name = "$name adv$name";
13c415cc 350 }
351 elseif ($contactType == 'Organization') {
352 $this->type("organization_name", $name);
353 }
354 else {
355 $this->type("household_name", $name);
6a488035
TO
356 }
357 $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]");
358 $this->waitForElementPresent("address_1_geo_code_2");
13c415cc 359 $this->type("email_1_email", $email);
360 $this->type("phone_1_phone", "9876543210");
6a488035 361 $this->type("address_1_street_address", $streetName);
86797006 362 $this->select("address_1_country_id", "UNITED STATES");
6a488035 363 $this->select("address_1_state_province_id", "Alaska");
13c415cc 364 $this->type("address_1_postal_code", $postalCode);
6a488035
TO
365
366 $this->click("//form[@id='Contact']/div[2]/div[6]/div[1]");
367 $this->waitForElementPresent("note");
368 $this->type("subject", "this is subject by $name");
369 $this->type("note", "this is notes by $name");
370
371 // save contact
372 $this->click("_qf_Contact_upload_view");
373 $this->waitForPageToLoad($this->getTimeoutMsec());
374 $this->assertTrue($this->isTextPresent("$name has been created."));
375 }
289c8051 376
a1a2a83d 377 /**
289c8051 378 * Webtest for CRM-12148
289c8051 379 */
00be9182 380 public function testSearchBuilderfinancialType() {
289c8051 381 $this->webtestLogin();
76e86fd8 382
289c8051
PN
383 // add financial type
384 $financialTypeName1 = 'Financial Type' . substr(sha1(rand()), 0, 5);;
385 $financialTypeName2 = 'Financial Type' . substr(sha1(rand()), 0, 5);;
386 $financialType = array(
387 'name' => $financialTypeName1,
388 'is_reserved' => FALSE,
389 'is_deductible' => FALSE,
390 );
391 $this->addeditFinancialType($financialType);
289c8051
PN
392 $financialType['name'] = $financialTypeName2;
393 $this->addeditFinancialType($financialType);
289c8051
PN
394 //create 6 contribution
395 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", "_qf_Contribution_upload");
396 for ($i = 1; $i <= 6; $i++) {
397 if ($i % 2 == 0) {
398 $financialType = $financialTypeName1;
399 }
400 else {
401 $financialType = $financialTypeName2;
402 }
403 // create new contact using dialog
80f3b91d 404 $this->createDialogContact();
289c8051
PN
405 $this->select('financial_type_id', $financialType);
406 $this->type('total_amount', 100 * $i);
225a8648 407 $this->clickLink('_qf_Contribution_upload_new', '_qf_Contribution_upload_new');
289c8051
PN
408 }
409 $this->openCiviPage("contact/search/builder", "reset=1", "_qf_Builder_refresh");
76e86fd8 410
289c8051 411 $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName1));
80f3b91d 412 $this->clickLink('_qf_Builder_refresh');
76e86fd8 413
289c8051 414 $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts');
76e86fd8 415
289c8051
PN
416 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
417 $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName2));
80f3b91d
CW
418 $this->clickLink('_qf_Builder_refresh');
419
289c8051 420 $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts');
76e86fd8 421
289c8051 422 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
13c415cc 423 $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, 'IN', array(
424 $financialTypeName1,
21dfd5f5 425 $financialTypeName2,
13c415cc 426 ));
80f3b91d
CW
427 $this->clickLink('_qf_Builder_refresh');
428
289c8051
PN
429 $this->assertTrue($this->isTextPresent('6 Contacts'), 'Missing text: ' . '6 Contacts');
430 }
3c53f77e 431
a1a2a83d 432 /**
3c53f77e 433 * Webtest for CRM-12588
3c53f77e 434 */
00be9182 435 public function testSearchBuilderMembershipType() {
3c53f77e
DL
436 $this->webtestLogin();
437
438 // create first contact
439 $firstName1 = substr(sha1(rand()), 0, 7);
440 $this->webtestAddContact($firstName1, "Memberson", "Memberson{$firstName1}@memberson.name");
441 $contactName1 = "Memberson, $firstName1";
442
443 // create Second contact
444 $firstName2 = substr(sha1(rand()), 0, 7);
445 $this->webtestAddContact($firstName2, "Memberson", "Memberson{$firstName2}@memberson.name");
446 $contactName2 = "Memberson, $firstName2";
447
448 // add membership type
449 $membershipTypes = $this->webtestAddMembershipType();
450
451 // now add membership
452 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
453
454 // select contact
455 $this->webtestFillAutocomplete($firstName1);
456
457 // fill in Membership Organization
1fd662d2 458 $this->waitForElementPresent("membership_type_id[0]");
3c53f77e
DL
459 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
460
461 // select membership type
4ea7e2aa 462 $this->waitForElementPresent("membership_type_id[1]");
3c53f77e
DL
463 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
464
465 // fill in Source
466 $this->type("source", "Membership StandaloneAddTest Webtest");
467
468 // fill in Start Date
469 $this->webtestFillDate('start_date');
470
471 // Clicking save.
1fd662d2 472 $this->click("_qf_Membership_upload");
3c53f77e
DL
473
474 // page was loaded
475 $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
476
477 // now add membership for second contact
478 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
479 $this->webtestFillAutocomplete($firstName2);
480 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
481 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
482 $this->type("source", "Membership StandaloneAddTest Webtest");
483 $this->webtestFillDate('start_date');
484
485 // fill in Status Override?
486 $this->click("is_override");
487 $this->waitForElementPresent("status_id");
488 $this->select("status_id", "label=Grace");
489
490 // Clicking save.
491 $this->clickLink("_qf_Membership_upload");
492 $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
493
494 // Open the search builder
495 $this->openCiviPage('contact/search/builder', 'reset=1');
496 $this->enterValues(1, 1, 'Membership', 'Membership Type', NULL, '=', array($membershipTypes['membership_type']));
497
498 $this->clickLink('_qf_Builder_refresh');
1fd662d2 499 $this->waitForAjaxContent();
d48ea865 500 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "2 Contacts");
3c53f77e
DL
501
502 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
503 $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, '=', array('New'));
504 $this->clickLink('_qf_Builder_refresh');
1fd662d2 505 $this->waitForAjaxContent();
d48ea865 506 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "1 Contact");
3c53f77e 507
02667514 508 $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, '=', array('Grace'));
3c53f77e 509 $this->clickLink('_qf_Builder_refresh');
1fd662d2 510 $this->waitForAjaxContent();
d48ea865 511 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "1 Contact");
3c53f77e
DL
512
513 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
c543dff8 514 $this->waitForElementPresent("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
3c53f77e 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 517 $this->clickLink('_qf_Builder_refresh');
1fd662d2 518 $this->waitForAjaxContent();
d48ea865 519 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "2 Contacts");
3c53f77e
DL
520
521 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
c543dff8 522 $this->waitForElementPresent("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
3c53f77e 523 $this->click("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
13c415cc 524 $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, 'IN', array('Current', 'Expired'));
3c53f77e
DL
525 $this->clickLink('_qf_Builder_refresh');
526 $this->waitForText("xpath=//form[@id='Builder']/div[3]/div/div", "No matches found for");
527
528 // Find Membership
529 $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh");
b9fdba0a 530 $this->select2('membership_type_id', $membershipTypes['membership_type'], TRUE);
3c53f77e 531 $this->clickLink('_qf_Search_refresh');
4ea7e2aa 532 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Result");
3c53f77e
DL
533
534 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
994bde4e 535 $this->multiselect2("membership_status_id", array("New", "Grace"));
3c53f77e 536 $this->clickLink('_qf_Search_refresh');
1fd662d2 537 $this->waitForAjaxContent();
d48ea865 538 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "2 Results");
3c53f77e 539
18aecc65 540 $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh");
c543dff8 541 $this->waitForAjaxContent();
3c53f77e 542 $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
b9fdba0a 543 $this->select2('membership_type_id', $membershipTypes['membership_type'], TRUE);
994bde4e 544 $this->multiselect2("membership_status_id", array("New"));
c543dff8 545 $this->click('_qf_Search_refresh');
1fd662d2 546 $this->waitForAjaxContent();
d48ea865 547 $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "1 Result");
3c53f77e
DL
548 }
549
6a488035 550}