Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testOfflineMembershipRenew() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
37 | // make sure period is correct for the membership type we testing for, | |
38 | // since it might have been modified by other tests | |
39 | // add membership type | |
40 | $membershipTypes = $this->webtestAddMembershipType('rolling', 2); | |
41 | ||
42 | // quick create a contact | |
43 | $firstName = substr(sha1(rand()), 0, 7); | |
44 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
45 | $contactName = "$firstName Memberson"; | |
46 | ||
47 | // click through to the membership tab | |
48 | $this->click('css=li#tab_member a'); | |
49 | ||
50 | $this->waitForElementPresent('link=Add Membership'); | |
51 | $this->click('link=Add Membership'); | |
52 | ||
53 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
54 | ||
55 | // fill in Membership Organization and Type | |
56 | $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}"); | |
57 | $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}"); | |
58 | ||
59 | // fill in Source | |
60 | $sourceText = 'Offline Membership Renewal Webtest'; | |
61 | $this->type('source', $sourceText); | |
62 | ||
63 | // Fill Member Since | |
64 | $this->webtestFillDate('join_date', '-2 year'); | |
65 | ||
66 | // Let Start Date and End Date be auto computed | |
efb29358 CW |
67 | |
68 | // Because it tends to cause problems, all uses of sleep() must be justified in comments | |
69 | // Sleep should never be used for wait for anything to load from the server | |
70 | // Justification for this instance: make sure onchange for total_amount has a chance to fire | |
6a488035 TO |
71 | sleep(2); |
72 | ||
73 | // Clicking save. | |
74 | $this->click('_qf_Membership_upload-bottom'); | |
75 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
76 | ||
77 | // page was loaded | |
78 | $this->waitForTextPresent($sourceText); | |
79 | ||
80 | // Is status message correct? | |
6c5f7368 | 81 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); |
6a488035 TO |
82 | |
83 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
84 | ||
85 | // click through to the Membership Renewal Link | |
86 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
87 | ||
88 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
89 | ||
90 | // save the renewed membership | |
91 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
92 | ||
93 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
94 | ||
95 | // page was loaded | |
96 | $this->waitForTextPresent($sourceText); | |
97 | ||
98 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
99 | ||
100 | // click through to the membership view screen | |
101 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
102 | ||
103 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
104 | ||
105 | $joinDate = $startDate = date('F jS, Y', strtotime("-2 year")); | |
106 | $endDate = date('F jS, Y', strtotime("+2 year -1 day")); | |
107 | ||
108 | // verify membership renewed | |
109 | $verifyMembershipRenewData = array( | |
110 | 'Member' => $contactName, | |
111 | 'Membership Type' => $membershipTypes['membership_type'], | |
112 | 'Status' => 'Current', | |
113 | 'Source' => $sourceText, | |
114 | 'Member Since' => $joinDate, | |
115 | 'Start date' => $startDate, | |
116 | 'End date' => $endDate, | |
117 | ); | |
f2ff7d84 PJ |
118 | $this->webtestVerifyTabularData($verifyMembershipRenewData); |
119 | } | |
6a488035 TO |
120 | |
121 | function testOfflineMemberRenewOverride() { | |
6a488035 TO |
122 | $this->webtestLogin(); |
123 | ||
124 | // add membership type | |
125 | $membershipTypes = $this->webtestAddMembershipType('rolling', 2); | |
126 | ||
127 | $firstName = substr(sha1(rand()), 0, 7); | |
128 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
129 | $contactName = "$firstName Memberson"; | |
130 | ||
131 | // click through to the membership tab | |
132 | $this->click('css=li#tab_member a'); | |
133 | ||
134 | $this->waitForElementPresent('link=Add Membership'); | |
135 | $this->click('link=Add Membership'); | |
136 | ||
137 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
138 | ||
139 | // fill in Membership Organization and Type | |
140 | $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}"); | |
141 | $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}"); | |
142 | ||
143 | // fill in Source | |
144 | $sourceText = 'Offline Membership Renewal Webtest'; | |
145 | $this->type('source', $sourceText); | |
146 | ||
147 | // Let Join Date stay default | |
148 | ||
149 | // fill in Start Date | |
150 | $this->webtestFillDate('start_date'); | |
151 | ||
152 | // Let End Date be auto computed | |
153 | ||
154 | // fill in Status Override? | |
155 | $this->click('is_override', 'value=1'); | |
156 | $this->waitForElementPresent('status_id'); | |
157 | $this->select('status_id', 'value=3'); | |
158 | ||
159 | // fill in Record Membership Payment? | |
160 | $this->click('record_contribution', 'value=1'); | |
161 | $this->waitForElementPresent('contribution_status_id'); | |
162 | ||
163 | // select the financial type for the selected membership type | |
164 | $this->select('financial_type_id', 'value=2'); | |
f2ff7d84 | 165 | |
6a488035 TO |
166 | // the amount for the selected membership type |
167 | $this->type('total_amount', '100.00'); | |
168 | ||
169 | // select payment instrument type = Check and enter chk number | |
170 | $this->select("payment_instrument_id", "value=4"); | |
171 | $this->waitForElementPresent("check_number"); | |
172 | $this->type("check_number", "check #12345"); | |
173 | $this->type("trxn_id", "P5476785" . rand(100, 10000)); | |
174 | ||
175 | // fill the payment status be default | |
176 | $this->select("contribution_status_id", "value=2"); | |
177 | ||
178 | // Clicking save. | |
179 | $this->click('_qf_Membership_upload-bottom'); | |
180 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
181 | ||
182 | // page was loaded | |
183 | $this->waitForTextPresent($sourceText); | |
184 | ||
185 | // Is status message correct? | |
6c5f7368 | 186 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); |
6a488035 TO |
187 | |
188 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
189 | ||
190 | // click through to the Membership Renewal Link | |
191 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
192 | ||
193 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
194 | ||
195 | // save the renewed membership | |
196 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
197 | ||
198 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
199 | ||
200 | // page was loaded | |
201 | $this->waitForTextPresent($sourceText); | |
202 | ||
203 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
204 | ||
205 | // click through to the membership view screen | |
206 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
207 | ||
208 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
209 | ||
210 | $joinDate = date('F jS, Y'); | |
211 | $startDate = date('F jS, Y', strtotime("+1 month")); | |
212 | $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day")); | |
213 | ||
214 | // verify membership renew override | |
215 | $verifyMembershipRenewOverrideData = array( | |
216 | 'Member' => $contactName, | |
217 | 'Membership Type' => $membershipTypes['membership_type'], | |
218 | 'Status' => 'New', | |
219 | 'Source' => $sourceText, | |
220 | 'Member Since' => $joinDate, | |
221 | 'Start date' => $startDate, | |
222 | 'End date' => $endDate, | |
223 | ); | |
f2ff7d84 | 224 | $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData); |
6a488035 TO |
225 | } |
226 | ||
227 | function testOfflineMembershipRenewChangeType() { | |
6a488035 TO |
228 | $this->webtestLogin(); |
229 | ||
230 | // make sure period is correct for the membership type we testing for, | |
231 | // since it might have been modified by other tests | |
232 | // add membership type | |
233 | $membershipTypes = $this->webtestAddMembershipType('rolling', 1); | |
234 | $newMembershipType = $this->webtestAddMembershipType('rolling', 1); | |
235 | ||
236 | $firstName = substr(sha1(rand()), 0, 7); | |
237 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
238 | $contactName = "$firstName Memberson"; | |
239 | ||
240 | // click through to the membership tab | |
241 | $this->click('css=li#tab_member a'); | |
242 | ||
243 | $this->waitForElementPresent('link=Add Membership'); | |
244 | $this->click('link=Add Membership'); | |
245 | ||
246 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
247 | ||
248 | // fill in Membership Organization and Type | |
249 | $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}"); | |
250 | $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}"); | |
251 | ||
252 | // fill in Source | |
253 | $sourceText = 'Offline Membership Renewal Webtest'; | |
254 | $this->type('source', $sourceText); | |
255 | ||
256 | // Fill Member Since | |
257 | $this->webtestFillDate('join_date', '-2 year'); | |
258 | ||
259 | // Let Start Date and End Date be auto computed | |
efb29358 CW |
260 | |
261 | // Because it tends to cause problems, all uses of sleep() must be justified in comments | |
262 | // Sleep should never be used for wait for anything to load from the server | |
263 | // Justification for this instance: make sure onchange for total_amount has a chance to fire | |
6a488035 TO |
264 | sleep(2); |
265 | ||
266 | // Clicking save. | |
267 | $this->click('_qf_Membership_upload-bottom'); | |
268 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
269 | ||
270 | // page was loaded | |
271 | $this->waitForTextPresent($sourceText); | |
272 | ||
273 | // Is status message correct? | |
6c5f7368 | 274 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); |
6a488035 TO |
275 | |
276 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
277 | ||
278 | // click through to the Membership Renewal Link | |
279 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
280 | ||
281 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
282 | ||
283 | //change membership type | |
284 | $this->click("changeMembershipOrgType"); | |
285 | $this->waitForElementPresent('membership_type_id[1]'); | |
286 | $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}"); | |
287 | $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}"); | |
288 | ||
289 | $this->click('membership_type_id[0]'); | |
efb29358 CW |
290 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
291 | // Sleep should never be used for wait for anything to load from the server | |
292 | // Justification for this instance: wait for onchange handler | |
6a488035 TO |
293 | sleep(2); |
294 | ||
295 | // save the renewed membership | |
296 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
297 | ||
298 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
299 | ||
300 | // page was loaded | |
301 | $this->waitForTextPresent($sourceText); | |
302 | ||
303 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
304 | ||
305 | // click through to the membership view screen | |
306 | $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
307 | ||
308 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
309 | ||
310 | $joinDate = date('F jS, Y', strtotime("-2 year")); | |
311 | $startDate = date('F jS, Y'); | |
312 | $endDate = date('F jS, Y', strtotime("+1 year -1 day")); | |
313 | ||
314 | // verify membership renewed and the membership type is changed | |
315 | $verifyMembershipData = array( | |
316 | 'Member' => $contactName, | |
317 | 'Membership Type' => $newMembershipType['membership_type'], | |
318 | 'Status' => 'Current', | |
319 | 'Source' => $sourceText, | |
320 | 'Member Since' => $joinDate, | |
321 | 'Start date' => $startDate, | |
322 | 'End date' => $endDate, | |
323 | ); | |
f2ff7d84 | 324 | $this->webtestVerifyTabularData($verifyMembershipData); |
6a488035 TO |
325 | } |
326 | ||
327 | function testOfflineMembershipRenewMultipleTerms() { | |
6a488035 TO |
328 | $this->webtestLogin(); |
329 | ||
330 | // make sure period is correct for the membership type we testing for, | |
331 | // since it might have been modified by other tests | |
332 | // add membership type | |
333 | $membershipTypes = $this->webtestAddMembershipType('rolling', 2); | |
334 | ||
335 | // quick create a contact | |
336 | $firstName = substr(sha1(rand()), 0, 7); | |
337 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
338 | $contactName = "$firstName Memberson"; | |
339 | ||
340 | // click through to the membership tab | |
341 | $this->click('css=li#tab_member a'); | |
342 | ||
343 | $this->waitForElementPresent('link=Add Membership'); | |
344 | $this->click('link=Add Membership'); | |
345 | ||
346 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
347 | ||
348 | // fill in Membership Organization and Type | |
349 | $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}"); | |
350 | $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}"); | |
351 | ||
352 | // fill in Source | |
353 | $sourceText = 'Offline Membership Renewal Webtest'; | |
354 | $this->type('source', $sourceText); | |
355 | ||
356 | // Fill Member Since | |
357 | $this->webtestFillDate('join_date', '-2 year'); | |
358 | ||
359 | // Let Start Date and End Date be auto computed | |
360 | ||
361 | // Record contribution | |
362 | $this->click('record_contribution'); | |
363 | $this->waitForElementPresent( 'financial_type_id' ); | |
364 | $this->select( 'financial_type_id', "label=Member Dues" ); | |
365 | $this->select('payment_instrument_id', "label=Check"); | |
366 | $this->waitForElementPresent('check_number'); | |
367 | $this->type('check_number', '1023'); | |
368 | $this->select('contribution_status_id', "label=Completed"); | |
369 | $this->click('send_receipt'); | |
efb29358 CW |
370 | |
371 | // Because it tends to cause problems, all uses of sleep() must be justified in comments | |
372 | // Sleep should never be used for wait for anything to load from the server | |
373 | // Justification for this instance: make sure onchange for total_amount has a chance to fire | |
6a488035 TO |
374 | sleep(2); |
375 | ||
376 | // Clicking save. | |
377 | $this->click('_qf_Membership_upload-bottom'); | |
378 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
379 | ||
380 | // page was loaded | |
381 | $this->waitForTextPresent($sourceText); | |
382 | ||
383 | // Is status message correct? | |
6c5f7368 CW |
384 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); |
385 | $this->waitForText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com."); | |
6a488035 TO |
386 | |
387 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
388 | ||
389 | // click through to the Membership Renewal Link | |
390 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); | |
391 | ||
392 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
393 | // Record contribution and set number of terms to 2 | |
394 | $this->click('record_contribution'); | |
f2ff7d84 | 395 | $this->waitForElementPresent('financial_type_id'); |
6a488035 TO |
396 | $this->click('changeTermsLink'); |
397 | $this->waitForElementPresent('num_terms'); | |
398 | $this->type('num_terms', ''); | |
399 | $this->type('num_terms', '2'); | |
efb29358 CW |
400 | |
401 | // Because it tends to cause problems, all uses of sleep() must be justified in comments | |
402 | // Sleep should never be used for wait for anything to load from the server | |
403 | // Justification for this instance: make sure onchange for total_amount has a chance to fire | |
6a488035 TO |
404 | sleep(2); |
405 | $this->click('total_amount'); | |
406 | $this->verifyValue('total_amount', "200.00"); | |
f2ff7d84 | 407 | $this->select('financial_type_id', "label=Member Dues"); |
6a488035 TO |
408 | $this->select('payment_instrument_id', "label=Check"); |
409 | $this->waitForElementPresent('check_number'); | |
410 | $this->type('check_number', '1024'); | |
411 | $this->select('contribution_status_id', "label=Completed"); | |
412 | $this->click('send_receipt'); | |
413 | ||
414 | // save the renewed membership | |
415 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
416 | ||
417 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
418 | ||
419 | // page was loaded | |
420 | $this->waitForTextPresent($sourceText); | |
421 | ||
422 | $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
423 | ||
424 | // click through to the membership view screen | |
425 | $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); | |
426 | ||
427 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
428 | ||
429 | $joinDate = $startDate = date('F jS, Y', strtotime("-2 year")); | |
430 | // Adding 2 x 2 years renewal to initial membership. | |
431 | $endDate = date('F jS, Y', strtotime("+4 year -1 day")); | |
432 | ||
433 | // verify membership renewed | |
434 | $verifyMembershipRenewData = array( | |
435 | 'Member' => $contactName, | |
436 | 'Membership Type' => $membershipTypes['membership_type'], | |
437 | 'Status' => 'Current', | |
438 | 'Source' => $sourceText, | |
439 | 'Member Since' => $joinDate, | |
440 | 'Start date' => $startDate, | |
441 | 'End date' => $endDate, | |
442 | ); | |
f2ff7d84 | 443 | $this->webtestVerifyTabularData($verifyMembershipRenewData); |
6a488035 | 444 | } |
42daf119 | 445 | } |