Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
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_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 | |
c79fb98e | 75 | $this->waitForAjaxContent(); |
6a488035 TO |
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."); |
c79fb98e | 85 | $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']"); |
6a488035 TO |
86 | |
87 | // click through to the Membership Renewal Link | |
c79fb98e | 88 | $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']"); |
6a488035 TO |
89 | |
90 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
91 | ||
92 | // save the renewed membership | |
93 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
94 | ||
6a488035 | 95 | // page was loaded |
5815ee4c | 96 | $this->waitForAjaxContent(); |
6a488035 | 97 | $this->waitForTextPresent($sourceText); |
c79fb98e | 98 | $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[1]/a[1][contains(text(),'View')]"); |
6a488035 TO |
99 | |
100 | // click through to the membership view screen | |
c79fb98e | 101 | $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[1]/a[1][contains(text(),'View')]"); |
6a488035 | 102 | |
e7066c8e | 103 | $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]"); |
6a488035 TO |
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 | 118 | $this->webtestVerifyTabularData($verifyMembershipRenewData); |
6c6e6187 | 119 | } |
6a488035 | 120 | |
00be9182 | 121 | public 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'); | |
6a488035 TO |
180 | |
181 | // page was loaded | |
182 | $this->waitForTextPresent($sourceText); | |
183 | ||
184 | // Is status message correct? | |
6c5f7368 | 185 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); |
6a488035 | 186 | |
00a86031 | 187 | $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']"); |
6a488035 TO |
188 | |
189 | // click through to the Membership Renewal Link | |
00a86031 | 190 | $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']"); |
6a488035 TO |
191 | |
192 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
193 | ||
194 | // save the renewed membership | |
195 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
196 | ||
6a488035 | 197 | // page was loaded |
6494453b | 198 | $this->waitForAjaxContent(); |
6a488035 | 199 | |
f08c3858 | 200 | $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]"); |
6a488035 TO |
201 | |
202 | // click through to the membership view screen | |
f64f0f3c | 203 | $this->waitForAjaxContent(); |
f58bc0ab | 204 | $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]"); |
6494453b | 205 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
6a488035 | 206 | |
92915c55 | 207 | $joinDate = date('F jS, Y'); |
6a488035 | 208 | $startDate = date('F jS, Y', strtotime("+1 month")); |
92915c55 | 209 | $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day")); |
6a488035 TO |
210 | |
211 | // verify membership renew override | |
212 | $verifyMembershipRenewOverrideData = array( | |
213 | 'Member' => $contactName, | |
214 | 'Membership Type' => $membershipTypes['membership_type'], | |
215 | 'Status' => 'New', | |
216 | 'Source' => $sourceText, | |
217 | 'Member Since' => $joinDate, | |
218 | 'Start date' => $startDate, | |
219 | 'End date' => $endDate, | |
220 | ); | |
f2ff7d84 | 221 | $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData); |
6a488035 TO |
222 | } |
223 | ||
00be9182 | 224 | public function testOfflineMembershipRenewChangeType() { |
6a488035 TO |
225 | $this->webtestLogin(); |
226 | ||
227 | // make sure period is correct for the membership type we testing for, | |
228 | // since it might have been modified by other tests | |
229 | // add membership type | |
230 | $membershipTypes = $this->webtestAddMembershipType('rolling', 1); | |
231 | $newMembershipType = $this->webtestAddMembershipType('rolling', 1); | |
232 | ||
233 | $firstName = substr(sha1(rand()), 0, 7); | |
234 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
235 | $contactName = "$firstName Memberson"; | |
236 | ||
237 | // click through to the membership tab | |
238 | $this->click('css=li#tab_member a'); | |
239 | ||
240 | $this->waitForElementPresent('link=Add Membership'); | |
241 | $this->click('link=Add Membership'); | |
242 | ||
243 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
244 | ||
245 | // fill in Membership Organization and Type | |
246 | $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}"); | |
247 | $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}"); | |
248 | ||
249 | // fill in Source | |
250 | $sourceText = 'Offline Membership Renewal Webtest'; | |
251 | $this->type('source', $sourceText); | |
252 | ||
253 | // Fill Member Since | |
254 | $this->webtestFillDate('join_date', '-2 year'); | |
255 | ||
256 | // Let Start Date and End Date be auto computed | |
efb29358 CW |
257 | |
258 | // Because it tends to cause problems, all uses of sleep() must be justified in comments | |
259 | // Sleep should never be used for wait for anything to load from the server | |
260 | // Justification for this instance: make sure onchange for total_amount has a chance to fire | |
c79fb98e | 261 | $this->waitForAjaxContent(); |
6a488035 TO |
262 | |
263 | // Clicking save. | |
264 | $this->click('_qf_Membership_upload-bottom'); | |
6a488035 TO |
265 | |
266 | // page was loaded | |
267 | $this->waitForTextPresent($sourceText); | |
268 | ||
269 | // Is status message correct? | |
6c5f7368 | 270 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); |
6a488035 | 271 | |
00a86031 | 272 | $this->waitForElementPresent("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']"); |
6a488035 TO |
273 | |
274 | // click through to the Membership Renewal Link | |
00a86031 | 275 | $this->click("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']"); |
6a488035 TO |
276 | |
277 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
278 | ||
279 | //change membership type | |
280 | $this->click("changeMembershipOrgType"); | |
281 | $this->waitForElementPresent('membership_type_id[1]'); | |
282 | $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}"); | |
283 | $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}"); | |
284 | ||
285 | $this->click('membership_type_id[0]'); | |
efb29358 CW |
286 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
287 | // Sleep should never be used for wait for anything to load from the server | |
288 | // Justification for this instance: wait for onchange handler | |
c79fb98e | 289 | $this->waitForAjaxContent(); |
6a488035 TO |
290 | |
291 | // save the renewed membership | |
292 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
293 | ||
6a488035 TO |
294 | // page was loaded |
295 | $this->waitForTextPresent($sourceText); | |
296 | ||
c543dff8 | 297 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']"); |
6a488035 TO |
298 | |
299 | // click through to the membership view screen | |
c543dff8 | 300 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']"); |
6a488035 TO |
301 | |
302 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
303 | ||
92915c55 | 304 | $joinDate = date('F jS, Y', strtotime("-2 year")); |
6a488035 | 305 | $startDate = date('F jS, Y'); |
92915c55 | 306 | $endDate = date('F jS, Y', strtotime("+1 year -1 day")); |
6a488035 TO |
307 | |
308 | // verify membership renewed and the membership type is changed | |
309 | $verifyMembershipData = array( | |
310 | 'Member' => $contactName, | |
311 | 'Membership Type' => $newMembershipType['membership_type'], | |
312 | 'Status' => 'Current', | |
313 | 'Source' => $sourceText, | |
314 | 'Member Since' => $joinDate, | |
315 | 'Start date' => $startDate, | |
316 | 'End date' => $endDate, | |
317 | ); | |
f2ff7d84 | 318 | $this->webtestVerifyTabularData($verifyMembershipData); |
6a488035 TO |
319 | } |
320 | ||
00be9182 | 321 | public function testOfflineMembershipRenewMultipleTerms() { |
6a488035 TO |
322 | $this->webtestLogin(); |
323 | ||
324 | // make sure period is correct for the membership type we testing for, | |
325 | // since it might have been modified by other tests | |
326 | // add membership type | |
327 | $membershipTypes = $this->webtestAddMembershipType('rolling', 2); | |
328 | ||
329 | // quick create a contact | |
330 | $firstName = substr(sha1(rand()), 0, 7); | |
331 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
332 | $contactName = "$firstName Memberson"; | |
333 | ||
334 | // click through to the membership tab | |
335 | $this->click('css=li#tab_member a'); | |
336 | ||
337 | $this->waitForElementPresent('link=Add Membership'); | |
338 | $this->click('link=Add Membership'); | |
339 | ||
340 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
341 | ||
342 | // fill in Membership Organization and Type | |
343 | $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}"); | |
344 | $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}"); | |
345 | ||
346 | // fill in Source | |
347 | $sourceText = 'Offline Membership Renewal Webtest'; | |
348 | $this->type('source', $sourceText); | |
349 | ||
350 | // Fill Member Since | |
351 | $this->webtestFillDate('join_date', '-2 year'); | |
352 | ||
353 | // Let Start Date and End Date be auto computed | |
354 | ||
355 | // Record contribution | |
481a74f4 TO |
356 | $this->waitForElementPresent('financial_type_id'); |
357 | $this->select('financial_type_id', "label=Member Dues"); | |
6a488035 TO |
358 | $this->select('payment_instrument_id', "label=Check"); |
359 | $this->waitForElementPresent('check_number'); | |
360 | $this->type('check_number', '1023'); | |
361 | $this->select('contribution_status_id', "label=Completed"); | |
362 | $this->click('send_receipt'); | |
efb29358 | 363 | |
eba7445e | 364 | $this->waitForElementPresent('_qf_Membership_upload-bottom'); |
6a488035 TO |
365 | |
366 | // Clicking save. | |
367 | $this->click('_qf_Membership_upload-bottom'); | |
6a488035 TO |
368 | |
369 | // page was loaded | |
370 | $this->waitForTextPresent($sourceText); | |
eba7445e | 371 | $endDate = $this->getText("xpath=//div[@id='memberships']//table/tbody/tr/td[4]"); |
6a488035 TO |
372 | |
373 | // Is status message correct? | |
eba7445e | 374 | $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added. The new membership End Date is {$endDate}. A membership confirmation and receipt has been sent to {$firstName}@memberson.com."); |
6a488035 | 375 | |
00a86031 | 376 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']"); |
6a488035 | 377 | // click through to the Membership Renewal Link |
00a86031 | 378 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']"); |
6a488035 TO |
379 | |
380 | $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); | |
381 | // Record contribution and set number of terms to 2 | |
382 | $this->click('record_contribution'); | |
f2ff7d84 | 383 | $this->waitForElementPresent('financial_type_id'); |
6a488035 TO |
384 | $this->click('changeTermsLink'); |
385 | $this->waitForElementPresent('num_terms'); | |
386 | $this->type('num_terms', ''); | |
387 | $this->type('num_terms', '2'); | |
eba7445e | 388 | $this->waitForElementPresent('total_amount'); |
6a488035 TO |
389 | $this->click('total_amount'); |
390 | $this->verifyValue('total_amount', "200.00"); | |
f2ff7d84 | 391 | $this->select('financial_type_id', "label=Member Dues"); |
6a488035 TO |
392 | $this->select('payment_instrument_id', "label=Check"); |
393 | $this->waitForElementPresent('check_number'); | |
394 | $this->type('check_number', '1024'); | |
395 | $this->select('contribution_status_id', "label=Completed"); | |
396 | $this->click('send_receipt'); | |
397 | ||
398 | // save the renewed membership | |
399 | $this->click('_qf_MembershipRenewal_upload-bottom'); | |
400 | ||
6a488035 TO |
401 | // page was loaded |
402 | $this->waitForTextPresent($sourceText); | |
403 | ||
c543dff8 | 404 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']"); |
6a488035 TO |
405 | |
406 | // click through to the membership view screen | |
c543dff8 | 407 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']"); |
6a488035 | 408 | |
eba7445e | 409 | $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]"); |
6a488035 TO |
410 | |
411 | $joinDate = $startDate = date('F jS, Y', strtotime("-2 year")); | |
412 | // Adding 2 x 2 years renewal to initial membership. | |
413 | $endDate = date('F jS, Y', strtotime("+4 year -1 day")); | |
414 | ||
415 | // verify membership renewed | |
416 | $verifyMembershipRenewData = array( | |
417 | 'Member' => $contactName, | |
418 | 'Membership Type' => $membershipTypes['membership_type'], | |
419 | 'Status' => 'Current', | |
420 | 'Source' => $sourceText, | |
421 | 'Member Since' => $joinDate, | |
422 | 'Start date' => $startDate, | |
423 | 'End date' => $endDate, | |
424 | ); | |
f2ff7d84 | 425 | $this->webtestVerifyTabularData($verifyMembershipRenewData); |
6a488035 | 426 | } |
96025800 | 427 | |
42daf119 | 428 | } |