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_AdvancedSearchTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testAdvanceSearch() { | |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
41 | ||
42 | //------- first create new group and tag ----- | |
43 | ||
44 | // take group name and create group | |
45 | $groupName = 'group_' . substr(sha1(rand()), 0, 7); | |
46 | $this->WebtestAddGroup($groupName); | |
47 | ||
48 | // take a tag name and create tag | |
49 | include_once 'WebTest/Contact/SearchTest.php'; | |
50 | $tagName = 'tag_' . substr(sha1(rand()), 0, 7); | |
51 | WebTest_Contact_SearchTest::addTag($tagName, $this); | |
52 | ||
53 | //---------- create detailed contact --------- | |
54 | ||
55 | $firstName = substr(sha1(rand()), 0, 7); | |
56 | $this->createDetailContact($firstName); | |
57 | ||
58 | // go to group tab and add to new group | |
59 | $this->click("css=li#tab_group a"); | |
60 | $this->waitForElementPresent("_qf_GroupContact_next"); | |
61 | $this->select("group_id", "$groupName"); | |
62 | $this->click("_qf_GroupContact_next"); | |
6a488035 TO |
63 | |
64 | // go to tag tab and add to new tag | |
65 | $this->click("css=li#tab_tag a"); | |
66 | $this->waitForElementPresent("css=div#tagtree"); | |
67 | $this->click("xpath=//ul/li/label[text()=\"$tagName\"]"); | |
68 | $this->waitForElementPresent("css=.success"); | |
79d6583c | 69 | |
6a488035 TO |
70 | // is status message correct? |
71 | $this->waitForTextPresent("Saved"); | |
6c5f7368 | 72 | $this->waitForText('crm-notification-container', "Saved"); |
6a488035 TO |
73 | |
74 | // go to event tab and register for event ( auto add activity and contribution ) | |
75 | $this->click("css=li#tab_participant a"); | |
76 | $this->waitForElementPresent("link=Add Event Registration"); | |
77 | $this->click("link=Add Event Registration"); | |
673c7418 | 78 | $this->waitForText('s2id_event_id', "- select event -"); |
6a488035 | 79 | // fall fundraiser dinner event label is variable |
673c7418 | 80 | $this->select2("event_id", "Fall Fundraiser Dinner"); |
6a488035 | 81 | $this->waitForElementPresent("receipt_text"); |
673c7418 | 82 | $this->multiselect2("role_id", array('Volunteer')); |
83 | $this->click("CIVICRM_QFID_17_4"); | |
6a488035 TO |
84 | $this->check("record_contribution"); |
85 | $this->waitForElementPresent("contribution_status_id"); | |
86 | $this->select("payment_instrument_id", "Check"); | |
87 | $this->type("check_number", "chqNo$firstName"); | |
88 | $this->type("trxn_id", "trid$firstName"); | |
89 | $this->click("_qf_Participant_upload-bottom"); | |
673c7418 | 90 | $this->waitForElementPresent("link=Add Event Registration"); |
6c5f7368 | 91 | $this->waitForText('crm-notification-container', "Event registration for $firstName adv$firstName has been added"); |
6a488035 TO |
92 | |
93 | // go to pledge tab and add pledge | |
94 | $this->click("css=li#tab_pledge a"); | |
95 | $this->waitForElementPresent("link=Add Pledge"); | |
96 | $this->click("link=Add Pledge"); | |
97 | $this->waitForElementPresent("contribution_page_id"); | |
98 | $this->type("amount", "200"); | |
99 | $this->type("installments", "5"); | |
100 | $this->type("frequency_interval", "1"); | |
101 | $this->select("frequency_unit", "month(s)"); | |
102 | $this->click("_qf_Pledge_upload-bottom"); | |
673c7418 | 103 | $this->waitForElementPresent("link=Add Pledge"); |
6a488035 | 104 | |
6c5f7368 | 105 | $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); |
6a488035 TO |
106 | |
107 | // go to Membership tab and add membership | |
108 | $this->click("css=li#tab_member a"); | |
109 | $this->waitForElementPresent("link=Add Membership"); | |
673c7418 | 110 | $this->clickLink("link=Add Membership", "_qf_Membership_cancel-bottom", FALSE); |
6a488035 | 111 | //let the organisation be default (Default Organization) |
0b96d6d4 | 112 | $this->select("membership_type_id[0]", "value=1"); |
6a488035 TO |
113 | $this->click("membership_type_id[1]"); |
114 | $this->select("membership_type_id[1]", "Student"); | |
115 | $this->type("source", "membership source$firstName"); | |
673c7418 | 116 | $this->clickLink("_qf_Membership_upload-bottom", "link=Add Membership", FALSE); |
6a488035 | 117 | |
6c5f7368 | 118 | $this->waitForText('crm-notification-container', "Student membership for $firstName adv$firstName has been added"); |
6a488035 TO |
119 | |
120 | // go to relationship tab and add relationship | |
121 | $this->click("css=li#tab_rel a"); | |
122 | $this->waitForElementPresent("link=Add Relationship"); | |
123 | $this->click("link=Add Relationship"); | |
124 | $this->waitForElementPresent("_qf_Relationship_cancel"); | |
673c7418 | 125 | $this->select2("relationship_type_id", "Employee of"); |
126 | $this->waitForElementPresent("xpath=//input[@id='related_contact_id'][@placeholder='- select organization -']"); | |
127 | $this->select2("related_contact_id", "Default", TRUE); | |
6a488035 TO |
128 | $this->webtestFillDate("start_date", "-1 day"); |
129 | $this->webtestFillDate("end_date", "+1 day"); | |
673c7418 | 130 | $this->click('_qf_Relationship_upload-bottom'); |
131 | $this->waitForText('crm-notification-container', "Relationship created."); | |
6a488035 TO |
132 | |
133 | //-------------- advance search -------------- | |
134 | ||
79d6583c | 135 | $this->openCiviPage('contact/search/advanced', 'reset=1'); |
6a488035 TO |
136 | |
137 | //also create a dummy name to test false | |
138 | $dummyName = substr(sha1(rand()), 0, 7); | |
139 | ||
140 | // search block array for adv search | |
141 | $searchBlockValues = array( | |
142 | 'basic' => array('', 'addBasicSearchDetail'), | |
143 | 'location' => array('state_province', 'addAddressSearchDetail'), | |
144 | 'demographics' => array('civicrm_gender_Transgender_3', 'addDemographicSearchDetail'), | |
145 | 'notes' => array('note', ''), | |
146 | 'activity' => array('activity_status[5]', 'addActivitySearchDetail'), | |
147 | 'CiviContribute' => array('contribution_currency_type', 'addContributionSearchDetail'), | |
148 | 'CiviEvent' => array('participant_fee_amount_high', 'addParticipantSearchDetail'), | |
149 | 'CiviMember' => array('member_end_date_high', 'addMemberSearchDetail'), | |
673c7418 | 150 | 'CiviPledge' => array('pledge_frequency_interval', 'addPledgeSearchDetail'), |
6a488035 TO |
151 | 'relationship' => array("xpath=//div[@id='relationship']/table/tbody/tr//td/label[text()='Relationship Status']/../label[text()='All']", ''), |
152 | ); | |
153 | ||
154 | foreach ($searchBlockValues as $block => $blockValues) { | |
155 | switch ($block) { | |
156 | case 'basic': | |
157 | $this->$blockValues[1]($firstName, $groupName, $tagName); | |
158 | break; | |
159 | ||
160 | case 'notes': | |
161 | $this->click("$block"); | |
162 | $this->waitForElementPresent("$blockValues[0]"); | |
163 | $this->type("note", "this is notes by $firstName"); | |
164 | break; | |
165 | ||
166 | case 'relationship': | |
167 | $this->click("$block"); | |
168 | $this->waitForElementPresent("$blockValues[0]"); | |
169 | $this->select("relation_type_id", "Employee of"); | |
170 | $this->type("relation_target_name", "Default"); | |
171 | break; | |
172 | ||
173 | default: | |
174 | $this->click("$block"); | |
175 | $this->waitForElementPresent("$blockValues[0]"); | |
176 | $this->$blockValues[1]($firstName); | |
177 | break; | |
178 | } | |
6a488035 TO |
179 | $this->submitSearch($firstName); |
180 | } | |
181 | ||
182 | //-- search with non existing value ( sort name ) | |
183 | $this->type("sort_name", "$dummyName"); | |
0b96d6d4 | 184 | $this->clickLink("_qf_Advanced_refresh"); |
377afa39 | 185 | $this->waitForText("xpath=//form[@id='Advanced']/div[3]/div/div", "No matches found for"); |
6a488035 TO |
186 | } |
187 | ||
188 | /* | |
189 | * Check for CRM-9873 | |
190 | */ | |
191 | function testActivitySearchByTypeTest() { | |
6a488035 | 192 | $this->webtestLogin(); |
79d6583c | 193 | $this->openCiviPage('contact/search/advanced', 'reset=1'); |
6a488035 | 194 | $this->click("activity"); |
79d6583c | 195 | $this->waitForElementPresent('activity_subject'); |
6a488035 TO |
196 | $this->check("xpath=//div[@id='Activity']//div/label[text()='Tell a Friend']/../input"); |
197 | $this->click("_qf_Advanced_refresh"); | |
198 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
199 | $count = explode(" ", trim($this->getText("xpath=//div[@id='search-status']/table/tbody/tr/td"))); | |
200 | $count = $count[0]; | |
201 | $this->assertTrue(is_numeric($count), "The total count of search results not found"); | |
202 | ||
203 | //pagination calculation | |
204 | $perPageRow = 50; | |
205 | if ($count > $perPageRow) { | |
206 | $cal = $count / $perPageRow; | |
207 | $mod = $count % $perPageRow; | |
208 | $j = 1; | |
209 | for ($i=1; $i<=$cal; $i++) { | |
210 | $subTotal = $i * $perPageRow; | |
211 | $lastPageSub = $subTotal + 1; | |
212 | ||
213 | //pagination and row count assertion | |
214 | $pagerCount = "Contact {$j} - {$subTotal} of {$count}"; | |
215 | $this->verifyText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", preg_quote($pagerCount)); | |
216 | $this->assertEquals($perPageRow, $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr")); | |
217 | ||
218 | //go to next page | |
219 | $this->click("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']/a[@title='next page']"); | |
673c7418 | 220 | $this->waitForElementPresent("Go"); |
6a488035 TO |
221 | $j = $j + $subTotal; |
222 | } | |
223 | ||
224 | //pagination and row count assertion for the remaining last page | |
225 | if ($mod) { | |
226 | $pagerCount = "Contact {$lastPageSub} - {$count} of {$count}"; | |
227 | $this->verifyText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", preg_quote($pagerCount)); | |
228 | $this->assertEquals($mod, $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr")); | |
229 | } | |
230 | } | |
231 | } | |
232 | ||
233 | //function to check match for sumbit Advance Search | |
4cbe18b8 EM |
234 | /** |
235 | * @param $firstName | |
236 | */ | |
6a488035 | 237 | function submitSearch($firstName) { |
0b96d6d4 | 238 | $this->clickLink("_qf_Advanced_refresh"); |
6a488035 | 239 | // verify unique name |
0b96d6d4 | 240 | $this->waitForText("xpath=//div[@class='crm-search-results']/table/tbody", preg_quote("adv$firstName, $firstName")); |
6a488035 TO |
241 | // should give 1 result only as we are searching with unique name |
242 | $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr/td", preg_quote("1 Contact")); | |
243 | // click to edit search | |
244 | $this->click("xpath=//form[@id='Advanced']//div[2]/div/div[1]"); | |
245 | } | |
246 | ||
247 | // function to fill auto complete | |
4cbe18b8 EM |
248 | /** |
249 | * @param $text | |
250 | * @param $elementId | |
251 | */ | |
6a488035 TO |
252 | function fillAutoComplete($text, $elementId) { |
253 | $this->click("$elementId"); | |
254 | $this->type("$elementId", "$text"); | |
255 | $this->typeKeys("$elementId", "$text"); | |
256 | $this->waitForElementPresent("css=div.ac_results li"); | |
257 | $this->click("css=div.ac_results li"); | |
258 | $this->assertContains($text, $this->getValue("$elementId"), | |
259 | "autocomplete expected $text but didn’t find it in " . $this->getValue("$elementId") | |
260 | ); | |
261 | } | |
262 | ||
48ebbfbe | 263 | /* |
264 | * Check for CRM-14952 | |
265 | */ | |
266 | function testStateSorting() { | |
267 | $this->webtestLogin(); | |
268 | $this->openCiviPage('contact/search/advanced', 'reset=1'); | |
269 | $this->waitForElementPresent('group'); | |
270 | $this->select2("group", "Newsletter", TRUE); | |
271 | $this->select2("group", "Advisory", TRUE); | |
272 | $this->click("location"); | |
273 | $this->waitForElementPresent('country'); | |
274 | $this->select2("country", "United States", False); | |
275 | $this->click("_qf_Advanced_refresh"); | |
276 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
277 | $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]"); | |
278 | $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]"); | |
279 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
280 | $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort); | |
281 | $this->click("xpath=//form[@id='Advanced']//div//div[contains(text(),'Edit Search Criteria')]/../div"); | |
282 | $this->waitForElementPresent('group'); | |
283 | $this->select2("group", "Summer", TRUE); | |
284 | $this->waitForElementPresent('state_province'); | |
285 | $this->select2("state_province", "Ohio", TRUE); | |
286 | $this->select2("state_province", "New York", TRUE); | |
287 | $this->select2("state_province", "New Mexico", TRUE); | |
288 | $this->select2("state_province", "Mississippi", TRUE); | |
289 | $this->select2("state_province", "Connecticut", TRUE); | |
290 | $this->select2("state_province", "Georgia", TRUE); | |
291 | $this->select2("state_province", "New Jersey", TRUE); | |
292 | $this->select2("state_province", "Texas", TRUE); | |
293 | $this->click("_qf_Advanced_refresh"); | |
294 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
295 | $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]"); | |
296 | $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]"); | |
297 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
298 | $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort); | |
299 | } | |
300 | ||
6a488035 | 301 | // function to fill basic search detail |
4cbe18b8 EM |
302 | /** |
303 | * @param $firstName | |
304 | * @param $groupName | |
305 | * @param $tagName | |
306 | */ | |
6a488035 TO |
307 | function addBasicSearchDetail($firstName, $groupName, $tagName) { |
308 | // fill partial sort name | |
309 | $this->type("sort_name", "$firstName"); | |
310 | // select subtype | |
673c7418 | 311 | $this->select("contact_type", "value=Individual\ 1Student"); |
6a488035 | 312 | // select group |
673c7418 | 313 | $this->select("group", "label=$groupName"); |
6a488035 | 314 | // select tag |
673c7418 | 315 | $this->select("contact_tags", "label=$tagName"); |
6a488035 TO |
316 | // select prefered language |
317 | $this->select("preferred_language", "value=en_US"); | |
318 | // select privacy | |
319 | $this->select("privacy_options", "value=do_not_email"); | |
320 | ||
321 | // select preferred communication method | |
322 | // phone | |
323 | $this->check("preferred_communication_method[1]"); | |
324 | ||
325 | $this->check("preferred_communication_method[2]"); | |
326 | } | |
327 | ||
328 | // function to fill address search block values in advance search | |
4cbe18b8 EM |
329 | /** |
330 | * @param $firstName | |
331 | */ | |
6a488035 TO |
332 | function addAddressSearchDetail($firstName) { |
333 | // select location type (home and main) | |
334 | $this->click("xpath=//div[@id='location']/table/tbody/tr[1]/td[1]//label[text()='Home']"); | |
335 | $this->click("xpath=//div[@id='location']/table/tbody/tr[1]/td[1]//label[text()='Main']"); | |
336 | // fill street address | |
337 | $this->type("street_address", "street 1 $firstName"); | |
338 | // fill city | |
339 | $this->type("city", "city$firstName"); | |
340 | // fill postal code range | |
341 | $this->type("postal_code_low", "100010"); | |
342 | $this->type("postal_code_high", "101000"); | |
343 | // select country | |
344 | $this->select("country", "United States"); | |
345 | // select state-province | |
346 | $this->select("state_province", "Alaska"); | |
347 | } | |
348 | ||
349 | // function to fill activity search block in advance search | |
4cbe18b8 EM |
350 | /** |
351 | * @param $firstName | |
352 | */ | |
6a488035 TO |
353 | function addActivitySearchDetail($firstName) { |
354 | // check activity types | |
355 | $checkActivityTypes = array("Contribution", "Event Registration", "Membership Signup"); | |
356 | foreach ($checkActivityTypes as $labels) { | |
673c7418 | 357 | $this->click("xpath=//div[@id='activity']/table/tbody/tr[2]/td[1]/div[1]//div/label[text()=\"$labels\"]"); |
6a488035 TO |
358 | } |
359 | // fill date range | |
360 | $this->select("activity_date_relative","value=0"); | |
361 | $this->webtestFillDate("activity_date_low", "-1 day"); | |
362 | $this->webtestFillDate("activity_date_high", "+1 day"); | |
363 | $this->type("activity_subject", "Student - membership source$firstName - Status: New"); | |
364 | // fill activity status | |
365 | ||
366 | $this->click("xpath=//div[@id='activity']/table/tbody//tr/td[2]/label[text()='Activity Status']/../label[text()='Scheduled']"); | |
367 | $this->click("xpath=//div[@id='activity']/table/tbody//tr/td[2]/label[text()='Activity Status']/../label[text()='Completed']"); | |
368 | } | |
369 | ||
370 | // function to fill demographic search details | |
371 | function addDemographicSearchDetail() { | |
372 | // fill birth date range | |
373 | $this->select("birth_date_relative","value=0"); | |
374 | $this->webtestFillDate("birth_date_low", "-3 year"); | |
375 | $this->webtestFillDate("birth_date_high", "now"); | |
376 | // fill deceased date range | |
377 | $this->click("xpath=//div[@id='demographics']/table/tbody//tr/td/label[text()='Deceased']/../label[text()='Yes']"); | |
378 | $this->select("deceased_date_relative","value=0"); | |
379 | $this->webtestFillDate("deceased_date_low", "-1 month"); | |
380 | $this->webtestFillDate("deceased_date_high", "+1 month"); | |
381 | // fill gender (male) | |
382 | $this->check("civicrm_gender_Male_2"); | |
383 | } | |
384 | ||
385 | //function to fill contribution search details | |
4cbe18b8 EM |
386 | /** |
387 | * @param $firstName | |
388 | */ | |
6a488035 TO |
389 | function addContributionSearchDetail($firstName) { |
390 | // fill contribution date range | |
391 | $this->select("contribution_date_relative","value=0"); | |
392 | $this->webtestFillDate("contribution_date_low", "-1 day"); | |
393 | $this->webtestFillDate("contribution_date_high", "+1 day"); | |
394 | // fill amount range | |
395 | $this->type("contribution_amount_low", "1"); | |
396 | $this->type("contribution_amount_high", "200"); | |
397 | // check for completed | |
398 | $this->check("contribution_status_id[1]"); | |
399 | // enter check number | |
400 | $this->select("contribution_payment_instrument_id", "Check"); | |
401 | $this->type("contribution_check_number", "chqNo$firstName"); | |
402 | // fill transaction id | |
403 | $this->type("contribution_transaction_id", "trid$firstName"); | |
404 | // fill financial type | |
405 | $this->select("financial_type_id", "Event Fee"); | |
406 | // fill currency type | |
407 | $this->select("contribution_currency_type", "USD"); | |
408 | } | |
409 | ||
410 | // function to fill participant search details | |
411 | function addParticipantSearchDetail() { | |
412 | // fill event name | |
673c7418 | 413 | $this->select2("event_id", "Fall Fundraiser Dinner"); |
6a488035 | 414 | // fill event type |
673c7418 | 415 | $this->select2("event_type_id", "Fundraiser"); |
6a488035 TO |
416 | // check participant status (registered) |
417 | $this->click("xpath=//div[@id='participantForm']/table/tbody//tr/td/label[text()='Participant Status']/../div//div/label[text()='Registered']"); | |
418 | // check participant role (Volunteer) | |
419 | $this->click("xpath=//div[@id='participantForm']/table/tbody//tr/td/label[text()='Participant Role']/../div//div/label[text()='Volunteer']"); | |
420 | // fill participant fee level (couple) | |
673c7418 | 421 | $this->select2("participant_fee_id", "Couple"); |
6a488035 TO |
422 | // fill amount range |
423 | $this->type("participant_fee_amount_low", "1"); | |
424 | $this->type("participant_fee_amount_high", "150"); | |
425 | } | |
426 | ||
427 | // function to fill member search details | |
4cbe18b8 EM |
428 | /** |
429 | * @param $firstName | |
430 | */ | |
6a488035 TO |
431 | function addMemberSearchDetail($firstName) { |
432 | // check membership type (Student) | |
433 | $this->click("xpath=//div[@id='memberForm']/table/tbody/tr[1]/td[1]/div[1]//div/label[text()='Student']"); | |
434 | // check membership status (completed) | |
435 | $this->click("xpath=//div[@id='memberForm']/table/tbody/tr[1]/td[2]/div[1]//div/label[text()='New']"); | |
436 | // fill member source | |
437 | $this->type("member_source", "membership source$firstName"); | |
438 | // check to search primary member | |
439 | $this->click("xpath=//div[@id='memberForm']/table/tbody/tr[2]/td[2]/p/input"); | |
440 | // add join date range | |
441 | $this->select("member_join_date_relative","value=0"); | |
442 | $this->webtestFillDate("member_join_date_low", "-1 day"); | |
443 | $this->webtestFillDate("member_join_date_high", "+1 day"); | |
444 | // add start date range | |
445 | $this->select("member_start_date_relative","value=0"); | |
446 | $this->webtestFillDate("member_start_date_low", "-1 day"); | |
447 | $this->webtestFillDate("member_start_date_high", "+1 day"); | |
448 | // add end date range | |
449 | $this->select("member_end_date_relative","value=0"); | |
450 | $this->webtestFillDate("member_end_date_low", "-1 year"); | |
451 | $this->webtestFillDate("member_end_date_high", "+2 year"); | |
452 | } | |
453 | ||
6a488035 | 454 | // function to fill member search details |
4cbe18b8 EM |
455 | /** |
456 | * @param $firstName | |
457 | */ | |
6a488035 TO |
458 | function addPledgeSearchDetail($firstName) { |
459 | // fill pledge schedule date range | |
460 | $this->select("pledge_payment_date_relative","value=0"); | |
461 | $this->webtestFillDate("pledge_payment_date_low", "-1 day"); | |
462 | $this->webtestFillDate("pledge_payment_date_high", "+1 day"); | |
463 | // fill Pledge payment status | |
464 | $this->click("xpath=//div[@id='pledgeForm']/table/tbody/tr[3]/td//label[text()='Completed']"); | |
465 | $this->click("xpath=//div[@id='pledgeForm']/table/tbody/tr[3]/td//label[text()='Pending']"); | |
466 | // fill pledge amount range | |
467 | $this->type("pledge_amount_low", "100"); | |
468 | $this->type("pledge_amount_high", "300"); | |
469 | // fill plegde status | |
470 | $this->click("xpath=//div[@id='pledgeForm']/table/tbody/tr[4]/td[2]//label[text()='Completed']"); | |
471 | $this->click("xpath=//div[@id='pledgeForm']/table/tbody/tr[4]/td[2]//label[text()='Pending']"); | |
472 | // fill pledge created date range | |
473 | $this->webtestFillDate("pledge_create_date_low", "-5 day"); | |
474 | $this->webtestFillDate("pledge_create_date_high", "+5 day"); | |
475 | // fill plegde start date | |
476 | $this->webtestFillDate("pledge_start_date_low", "-2 day"); | |
477 | $this->webtestFillDate("pledge_start_date_high", "+2 day"); | |
478 | // fill financial type | |
479 | $this->select("pledge_financial_type_id", "Donation"); | |
480 | } | |
481 | ||
482 | // function to create contact with details (contact details, address, Constituent information ...) | |
4cbe18b8 EM |
483 | /** |
484 | * @param null $firstName | |
485 | */ | |
6a488035 TO |
486 | function createDetailContact($firstName = NULL) { |
487 | if (!$firstName) { | |
488 | $firstName = substr(sha1(rand()), 0, 7); | |
489 | } | |
490 | ||
491 | // create contact type Individual with subtype | |
492 | // with most of values to required to search | |
493 | $Subtype = "Student"; | |
79d6583c | 494 | $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel'); |
6a488035 TO |
495 | |
496 | // --- fill few values in Contact Detail block | |
497 | $this->type("first_name", "$firstName"); | |
498 | $this->type("middle_name", "mid$firstName"); | |
499 | $this->type("last_name", "adv$firstName"); | |
673c7418 | 500 | $this->select("contact_sub_type", "label=$Subtype"); |
6a488035 TO |
501 | $this->type("email_1_email", "$firstName@advsearch.co.in"); |
502 | $this->type("phone_1_phone", "123456789"); | |
503 | $this->type("external_identifier", "extid$firstName"); | |
504 | ||
505 | // --- fill few value in Constituent information | |
506 | $this->click("customData1"); | |
507 | $this->waitForElementPresent("custom_3_-1"); | |
508 | ||
509 | $this->click("CIVICRM_QFID_Edu_2"); | |
510 | $this->select("custom_2_-1", "label=Single"); | |
511 | ||
512 | // --- fill few values in address | |
513 | ||
514 | $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]"); | |
515 | $this->waitForElementPresent("address_1_geo_code_2"); | |
516 | $this->type("address_1_street_address", "street 1 $firstName"); | |
517 | $this->type("address_1_supplemental_address_1", "street supplement 1 $firstName"); | |
518 | $this->type("address_1_supplemental_address_2", "street supplement 2 $firstName"); | |
519 | $this->type("address_1_city", "city$firstName"); | |
520 | $this->type("address_1_postal_code", "100100"); | |
521 | $this->select("address_1_country_id", "United States"); | |
522 | $this->select("address_1_state_province_id", "Alaska"); | |
523 | ||
524 | // --- fill few values in communication preferences | |
525 | $this->click("//form[@id='Contact']/div[2]/div[5]/div[1]"); | |
526 | $this->waitForElementPresent("preferred_mail_format"); | |
527 | $this->check("privacy[do_not_phone]"); | |
528 | $this->check("privacy[do_not_mail]"); | |
529 | // phone | |
530 | $this->check("preferred_communication_method[1]"); | |
531 | ||
532 | $this->check("preferred_communication_method[2]"); | |
533 | $this->select("preferred_language", "value=en_US"); | |
534 | ||
535 | // --- fill few value in notes | |
536 | $this->click("//form[@id='Contact']/div[2]/div[6]/div[1]"); | |
537 | $this->waitForElementPresent("note"); | |
538 | $this->type("subject", "this is subject by $firstName"); | |
539 | $this->type("note", "this is notes by $firstName"); | |
540 | ||
541 | // --- fill few values in demographics | |
542 | $this->click("//form[@id='Contact']/div[2]/div[7]/div[1]"); | |
543 | $this->waitForElementPresent("is_deceased"); | |
544 | $this->click("civicrm_gender_Male_2"); | |
545 | ||
546 | $this->webtestFillDate("birth_date", "-1 year"); | |
547 | $this->click("is_deceased"); | |
548 | $this->waitForElementPresent("deceased_date"); | |
549 | $this->webtestFillDate("deceased_date", "now"); | |
550 | ||
551 | // save contact | |
552 | $this->click("_qf_Contact_upload_view"); | |
553 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
79d6583c | 554 | $this->assertElementContainsText('css=.crm-summary-display_name', "$firstName adv$firstName"); |
6a488035 TO |
555 | } |
556 | } | |
557 |