3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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';
30 * Class WebTest_Member_OfflineMembershipRenewTest
32 class WebTest_Member_OfflineMembershipRenewTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testOfflineMembershipRenew() {
39 $this->webtestLogin();
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);
46 // quick create a contact
47 $firstName = substr(sha1(rand()), 0, 7);
48 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
49 $contactName = "$firstName Memberson";
51 // click through to the membership tab
52 $this->click('css=li#tab_member a');
54 $this->waitForElementPresent('link=Add Membership');
55 $this->click('link=Add Membership');
57 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
64 $sourceText = 'Offline Membership Renewal Webtest';
65 $this->type('source', $sourceText);
68 $this->webtestFillDate('join_date', '-2 year');
70 // Let Start Date and End Date be auto computed
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
75 $this->waitForAjaxContent();
78 $this->click('_qf_Membership_upload-bottom');
81 $this->waitForTextPresent($sourceText);
83 // Is status message correct?
84 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
85 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
87 // click through to the Membership Renewal Link
88 $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
90 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
92 // save the renewed membership
93 $this->click('_qf_MembershipRenewal_upload-bottom');
96 $this->waitForAjaxContent();
97 $this->waitForTextPresent($sourceText);
98 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[1]/a[1][contains(text(),'View')]");
100 // click through to the membership view screen
101 $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[1]/a[1][contains(text(),'View')]");
103 $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
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 public 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');
182 $this->waitForTextPresent($sourceText);
184 // Is status message correct?
185 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
187 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']");
189 // click through to the Membership Renewal Link
190 $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']");
192 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
194 // save the renewed membership
195 $this->click('_qf_MembershipRenewal_upload-bottom');
198 $this->waitForAjaxContent();
200 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]");
202 // click through to the membership view screen
203 $this->waitForAjaxContent();
204 $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]");
205 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
207 $joinDate = date('F jS, Y');
208 $startDate = date('F jS, Y', strtotime("+1 month"));
209 $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day"));
211 // verify membership renew override
212 $verifyMembershipRenewOverrideData = array(
213 'Member' => $contactName,
214 'Membership Type' => $membershipTypes['membership_type'],
216 'Source' => $sourceText,
217 'Member Since' => $joinDate,
218 'Start date' => $startDate,
219 'End date' => $endDate,
221 $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
224 public function testOfflineMembershipRenewChangeType() {
225 $this->webtestLogin();
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);
233 $firstName = substr(sha1(rand()), 0, 7);
234 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
235 $contactName = "$firstName Memberson";
237 // click through to the membership tab
238 $this->click('css=li#tab_member a');
240 $this->waitForElementPresent('link=Add Membership');
241 $this->click('link=Add Membership');
243 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
250 $sourceText = 'Offline Membership Renewal Webtest';
251 $this->type('source', $sourceText);
254 $this->webtestFillDate('join_date', '-2 year');
256 // Let Start Date and End Date be auto computed
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
261 $this->waitForAjaxContent();
264 $this->click('_qf_Membership_upload-bottom');
267 $this->waitForTextPresent($sourceText);
269 // Is status message correct?
270 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
272 $this->waitForElementPresent("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
274 // click through to the Membership Renewal Link
275 $this->click("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
277 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
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']}");
285 $this->click('membership_type_id[0]');
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
289 $this->waitForAjaxContent();
291 // save the renewed membership
292 $this->click('_qf_MembershipRenewal_upload-bottom');
295 $this->waitForTextPresent($sourceText);
297 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
299 // click through to the membership view screen
300 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
302 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
304 $joinDate = date('F jS, Y', strtotime("-2 year"));
305 $startDate = date('F jS, Y');
306 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
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,
318 $this->webtestVerifyTabularData($verifyMembershipData);
321 public function testOfflineMembershipRenewMultipleTerms() {
322 $this->webtestLogin();
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);
329 // quick create a contact
330 $firstName = substr(sha1(rand()), 0, 7);
331 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
332 $contactName = "$firstName Memberson";
334 // click through to the membership tab
335 $this->click('css=li#tab_member a');
337 $this->waitForElementPresent('link=Add Membership');
338 $this->click('link=Add Membership');
340 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
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']}");
347 $sourceText = 'Offline Membership Renewal Webtest';
348 $this->type('source', $sourceText);
351 $this->webtestFillDate('join_date', '-2 year');
353 // Let Start Date and End Date be auto computed
355 // Record contribution
356 $this->waitForElementPresent('financial_type_id');
357 $this->select('financial_type_id', "label=Member Dues");
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');
364 $this->waitForElementPresent('_qf_Membership_upload-bottom');
367 $this->click('_qf_Membership_upload-bottom');
370 $this->waitForTextPresent($sourceText);
371 $endDate = $this->getText("xpath=//div[@id='memberships']//table/tbody/tr/td[4]");
373 // Is status message correct?
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.");
376 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
377 // click through to the Membership Renewal Link
378 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
380 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
381 // Record contribution and set number of terms to 2
382 $this->click('record_contribution');
383 $this->waitForElementPresent('financial_type_id');
384 $this->click('changeTermsLink');
385 $this->waitForElementPresent('num_terms');
386 $this->type('num_terms', '');
387 $this->type('num_terms', '2');
388 $this->waitForElementPresent('total_amount');
389 $this->click('total_amount');
390 $this->verifyValue('total_amount', "200.00");
391 $this->select('financial_type_id', "label=Member Dues");
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');
398 // save the renewed membership
399 $this->click('_qf_MembershipRenewal_upload-bottom');
402 $this->waitForTextPresent($sourceText);
404 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
406 // click through to the membership view screen
407 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
409 $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
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"));
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,
425 $this->webtestVerifyTabularData($verifyMembershipRenewData);