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