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