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