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