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