3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Member_OfflineMembershipRenewTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testOfflineMembershipRenew() {
35 $this->webtestLogin();
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);
42 // quick create a contact
43 $firstName = substr(sha1(rand()), 0, 7);
44 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
45 $contactName = "$firstName Memberson";
47 // click through to the membership tab
48 $this->click('css=li#tab_member a');
50 $this->waitForElementPresent('link=Add Membership');
51 $this->click('link=Add Membership');
53 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
60 $sourceText = 'Offline Membership Renewal Webtest';
61 $this->type('source', $sourceText);
64 $this->webtestFillDate('join_date', '-2 year');
66 // Let Start Date and End Date be auto computed
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
74 $this->click('_qf_Membership_upload-bottom');
75 $this->waitForPageToLoad($this->getTimeoutMsec());
78 $this->waitForTextPresent($sourceText);
80 // Is status message correct?
81 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
83 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
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']");
88 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
90 // save the renewed membership
91 $this->click('_qf_MembershipRenewal_upload-bottom');
93 $this->waitForPageToLoad($this->getTimeoutMsec());
96 $this->waitForTextPresent($sourceText);
98 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
100 // click through to the membership view screen
101 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
103 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
105 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
106 $endDate = date('F jS, Y', strtotime("+2 year -1 day"));
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,
118 $this->webtestVerifyTabularData($verifyMembershipRenewData);
121 function testOfflineMemberRenewOverride() {
122 $this->webtestLogin();
124 // add membership type
125 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
127 $firstName = substr(sha1(rand()), 0, 7);
128 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
129 $contactName = "$firstName Memberson";
131 // click through to the membership tab
132 $this->click('css=li#tab_member a');
134 $this->waitForElementPresent('link=Add Membership');
135 $this->click('link=Add Membership');
137 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
144 $sourceText = 'Offline Membership Renewal Webtest';
145 $this->type('source', $sourceText);
147 // Let Join Date stay default
149 // fill in Start Date
150 $this->webtestFillDate('start_date');
152 // Let End Date be auto computed
154 // fill in Status Override?
155 $this->click('is_override', 'value=1');
156 $this->waitForElementPresent('status_id');
157 $this->select('status_id', 'value=3');
159 // fill in Record Membership Payment?
160 $this->click('record_contribution', 'value=1');
161 $this->waitForElementPresent('contribution_status_id');
163 // select the financial type for the selected membership type
164 $this->select('financial_type_id', 'value=2');
166 // the amount for the selected membership type
167 $this->type('total_amount', '100.00');
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));
175 // fill the payment status be default
176 $this->select("contribution_status_id", "value=2");
179 $this->click('_qf_Membership_upload-bottom');
180 $this->waitForPageToLoad($this->getTimeoutMsec());
183 $this->waitForTextPresent($sourceText);
185 // Is status message correct?
186 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
188 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
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']");
193 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
195 // save the renewed membership
196 $this->click('_qf_MembershipRenewal_upload-bottom');
198 $this->waitForPageToLoad($this->getTimeoutMsec());
201 $this->waitForTextPresent($sourceText);
203 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
205 // click through to the membership view screen
206 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
208 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
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"));
214 // verify membership renew override
215 $verifyMembershipRenewOverrideData = array(
216 'Member' => $contactName,
217 'Membership Type' => $membershipTypes['membership_type'],
219 'Source' => $sourceText,
220 'Member Since' => $joinDate,
221 'Start date' => $startDate,
222 'End date' => $endDate,
224 $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
227 function testOfflineMembershipRenewChangeType() {
228 $this->webtestLogin();
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);
236 $firstName = substr(sha1(rand()), 0, 7);
237 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
238 $contactName = "$firstName Memberson";
240 // click through to the membership tab
241 $this->click('css=li#tab_member a');
243 $this->waitForElementPresent('link=Add Membership');
244 $this->click('link=Add Membership');
246 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
253 $sourceText = 'Offline Membership Renewal Webtest';
254 $this->type('source', $sourceText);
257 $this->webtestFillDate('join_date', '-2 year');
259 // Let Start Date and End Date be auto computed
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
267 $this->click('_qf_Membership_upload-bottom');
268 $this->waitForPageToLoad($this->getTimeoutMsec());
271 $this->waitForTextPresent($sourceText);
273 // Is status message correct?
274 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
276 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
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']");
281 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
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']}");
289 $this->click('membership_type_id[0]');
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
295 // save the renewed membership
296 $this->click('_qf_MembershipRenewal_upload-bottom');
298 $this->waitForPageToLoad($this->getTimeoutMsec());
301 $this->waitForTextPresent($sourceText);
303 $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
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']");
308 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
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"));
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,
324 $this->webtestVerifyTabularData($verifyMembershipData);
327 function testOfflineMembershipRenewMultipleTerms() {
328 $this->webtestLogin();
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);
335 // quick create a contact
336 $firstName = substr(sha1(rand()), 0, 7);
337 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
338 $contactName = "$firstName Memberson";
340 // click through to the membership tab
341 $this->click('css=li#tab_member a');
343 $this->waitForElementPresent('link=Add Membership');
344 $this->click('link=Add Membership');
346 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
353 $sourceText = 'Offline Membership Renewal Webtest';
354 $this->type('source', $sourceText);
357 $this->webtestFillDate('join_date', '-2 year');
359 // Let Start Date and End Date be auto computed
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');
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
377 $this->click('_qf_Membership_upload-bottom');
378 $this->waitForPageToLoad($this->getTimeoutMsec());
381 $this->waitForTextPresent($sourceText);
383 // Is status message correct?
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.");
387 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
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']");
392 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
393 // Record contribution and set number of terms to 2
394 $this->click('record_contribution');
395 $this->waitForElementPresent('financial_type_id');
396 $this->click('changeTermsLink');
397 $this->waitForElementPresent('num_terms');
398 $this->type('num_terms', '');
399 $this->type('num_terms', '2');
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
405 $this->click('total_amount');
406 $this->verifyValue('total_amount', "200.00");
407 $this->select('financial_type_id', "label=Member Dues");
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');
414 // save the renewed membership
415 $this->click('_qf_MembershipRenewal_upload-bottom');
417 $this->waitForPageToLoad($this->getTimeoutMsec());
420 $this->waitForTextPresent($sourceText);
422 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
424 // click through to the membership view screen
425 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
427 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
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"));
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,
443 $this->webtestVerifyTabularData($verifyMembershipRenewData);