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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Member_OfflineMembershipRenewTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testOfflineMembershipRenew() {
36 $this->webtestLogin();
38 // make sure period is correct for the membership type we testing for,
39 // since it might have been modified by other tests
40 // add membership type
41 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
43 // quick create a contact
44 $firstName = substr(sha1(rand()), 0, 7);
45 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
46 $contactName = "$firstName Memberson";
48 // click through to the membership tab
49 $this->click('css=li#tab_member a');
51 $this->waitForElementPresent('link=Add Membership');
52 $this->click('link=Add Membership');
54 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
56 // fill in Membership Organization and Type
57 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
58 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
61 $sourceText = 'Offline Membership Renewal Webtest';
62 $this->type('source', $sourceText);
65 $this->webtestFillDate('join_date', '-2 year');
67 // Let Start Date and End Date be auto computed
68 // added sleep to make sure jscript onchange for total_amount has a chance to fire
72 $this->click('_qf_Membership_upload-bottom');
73 $this->waitForPageToLoad($this->getTimeoutMsec());
76 $this->waitForTextPresent($sourceText);
78 // Is status message correct?
79 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
80 "Status message didn't show up after saving!"
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->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
187 "Status message didn't show up after saving!"
190 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
192 // click through to the Membership Renewal Link
193 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
195 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
197 // save the renewed membership
198 $this->click('_qf_MembershipRenewal_upload-bottom');
200 $this->waitForPageToLoad($this->getTimeoutMsec());
203 $this->waitForTextPresent($sourceText);
205 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
207 // click through to the membership view screen
208 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
210 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
212 $joinDate = date('F jS, Y');
213 $startDate = date('F jS, Y', strtotime("+1 month"));
214 $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day"));
216 // verify membership renew override
217 $verifyMembershipRenewOverrideData = array(
218 'Member' => $contactName,
219 'Membership Type' => $membershipTypes['membership_type'],
221 'Source' => $sourceText,
222 'Member Since' => $joinDate,
223 'Start date' => $startDate,
224 'End date' => $endDate,
226 $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
229 function testOfflineMembershipRenewChangeType() {
230 $this->webtestLogin();
232 // make sure period is correct for the membership type we testing for,
233 // since it might have been modified by other tests
234 // add membership type
235 $membershipTypes = $this->webtestAddMembershipType('rolling', 1);
236 $newMembershipType = $this->webtestAddMembershipType('rolling', 1);
238 $firstName = substr(sha1(rand()), 0, 7);
239 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
240 $contactName = "$firstName Memberson";
242 // click through to the membership tab
243 $this->click('css=li#tab_member a');
245 $this->waitForElementPresent('link=Add Membership');
246 $this->click('link=Add Membership');
248 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
250 // fill in Membership Organization and Type
251 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
252 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
255 $sourceText = 'Offline Membership Renewal Webtest';
256 $this->type('source', $sourceText);
259 $this->webtestFillDate('join_date', '-2 year');
261 // Let Start Date and End Date be auto computed
262 // added sleep to make sure jscript onchange for total_amount has a chance to fire
266 $this->click('_qf_Membership_upload-bottom');
267 $this->waitForPageToLoad($this->getTimeoutMsec());
270 $this->waitForTextPresent($sourceText);
272 // Is status message correct?
273 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
274 "Status message didn't show up after saving!"
277 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
279 // click through to the Membership Renewal Link
280 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
282 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
284 //change membership type
285 $this->click("changeMembershipOrgType");
286 $this->waitForElementPresent('membership_type_id[1]');
287 $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}");
288 $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}");
290 $this->click('membership_type_id[0]');
293 // save the renewed membership
294 $this->click('_qf_MembershipRenewal_upload-bottom');
296 $this->waitForPageToLoad($this->getTimeoutMsec());
299 $this->waitForTextPresent($sourceText);
301 $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
303 // click through to the membership view screen
304 $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
306 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
308 $joinDate = date('F jS, Y', strtotime("-2 year"));
309 $startDate = date('F jS, Y');
310 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
312 // verify membership renewed and the membership type is changed
313 $verifyMembershipData = array(
314 'Member' => $contactName,
315 'Membership Type' => $newMembershipType['membership_type'],
316 'Status' => 'Current',
317 'Source' => $sourceText,
318 'Member Since' => $joinDate,
319 'Start date' => $startDate,
320 'End date' => $endDate,
322 $this->webtestVerifyTabularData($verifyMembershipData);
325 function testOfflineMembershipRenewMultipleTerms() {
326 $this->webtestLogin();
328 // make sure period is correct for the membership type we testing for,
329 // since it might have been modified by other tests
330 // add membership type
331 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
333 // quick create a contact
334 $firstName = substr(sha1(rand()), 0, 7);
335 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
336 $contactName = "$firstName Memberson";
338 // click through to the membership tab
339 $this->click('css=li#tab_member a');
341 $this->waitForElementPresent('link=Add Membership');
342 $this->click('link=Add Membership');
344 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
346 // fill in Membership Organization and Type
347 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
348 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
351 $sourceText = 'Offline Membership Renewal Webtest';
352 $this->type('source', $sourceText);
355 $this->webtestFillDate('join_date', '-2 year');
357 // Let Start Date and End Date be auto computed
359 // Record contribution
360 $this->click('record_contribution');
361 $this->waitForElementPresent( 'financial_type_id' );
362 $this->select( 'financial_type_id', "label=Member Dues" );
363 $this->select('payment_instrument_id', "label=Check");
364 $this->waitForElementPresent('check_number');
365 $this->type('check_number', '1023');
366 $this->select('contribution_status_id', "label=Completed");
367 $this->click('send_receipt');
368 // added sleep to make sure jscript onchange for total_amount has a chance to fire
372 $this->click('_qf_Membership_upload-bottom');
373 $this->waitForPageToLoad($this->getTimeoutMsec());
376 $this->waitForTextPresent($sourceText);
378 // Is status message correct?
379 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
380 "Status message didn't show up after saving!"
382 $this->assertElementContainsText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com.",
383 "Email sent to member message didn't show up after saving membership!"
386 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
388 // click through to the Membership Renewal Link
389 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
391 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
392 // Record contribution and set number of terms to 2
393 $this->click('record_contribution');
394 $this->waitForElementPresent('financial_type_id');
395 $this->click('changeTermsLink');
396 $this->waitForElementPresent('num_terms');
397 $this->type('num_terms', '');
398 $this->type('num_terms', '2');
399 // added sleep to make sure jscript onchange for total_amount has a chance to fire
401 $this->click('total_amount');
402 $this->verifyValue('total_amount', "200.00");
403 $this->select('financial_type_id', "label=Member Dues");
404 $this->select('payment_instrument_id', "label=Check");
405 $this->waitForElementPresent('check_number');
406 $this->type('check_number', '1024');
407 $this->select('contribution_status_id', "label=Completed");
408 $this->click('send_receipt');
410 // save the renewed membership
411 $this->click('_qf_MembershipRenewal_upload-bottom');
413 $this->waitForPageToLoad($this->getTimeoutMsec());
416 $this->waitForTextPresent($sourceText);
418 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
420 // click through to the membership view screen
421 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
423 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
425 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
426 // Adding 2 x 2 years renewal to initial membership.
427 $endDate = date('F jS, Y', strtotime("+4 year -1 day"));
429 // verify membership renewed
430 $verifyMembershipRenewData = array(
431 'Member' => $contactName,
432 'Membership Type' => $membershipTypes['membership_type'],
433 'Status' => 'Current',
434 'Source' => $sourceText,
435 'Member Since' => $joinDate,
436 'Start date' => $startDate,
437 'End date' => $endDate,
439 $this->webtestVerifyTabularData($verifyMembershipRenewData);