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