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->open($this->sboxPath
);
37 $this->webtestLogin();
39 // make sure period is correct for the membership type we testing for,
40 // since it might have been modified by other tests
41 // add membership type
42 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
44 // quick create a contact
45 $firstName = substr(sha1(rand()), 0, 7);
46 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
47 $contactName = "$firstName Memberson";
49 // click through to the membership tab
50 $this->click('css=li#tab_member a');
52 $this->waitForElementPresent('link=Add Membership');
53 $this->click('link=Add Membership');
55 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
57 // fill in Membership Organization and Type
58 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
59 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
62 $sourceText = 'Offline Membership Renewal Webtest';
63 $this->type('source', $sourceText);
66 $this->webtestFillDate('join_date', '-2 year');
68 // Let Start Date and End Date be auto computed
69 // added sleep to make sure jscript onchange for total_amount has a chance to fire
73 $this->click('_qf_Membership_upload-bottom');
74 $this->waitForPageToLoad($this->getTimeoutMsec());
77 $this->waitForTextPresent($sourceText);
79 // Is status message correct?
80 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
81 "Status message didn't show up after saving!"
84 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
86 // click through to the Membership Renewal Link
87 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
89 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
91 // save the renewed membership
92 $this->click('_qf_MembershipRenewal_upload-bottom');
94 $this->waitForPageToLoad($this->getTimeoutMsec());
97 $this->waitForTextPresent($sourceText);
99 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
101 // click through to the membership view screen
102 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
104 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
106 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
107 $endDate = date('F jS, Y', strtotime("+2 year -1 day"));
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,
119 $this->webtestVerifyTabularData($verifyMembershipRenewData);
122 function testOfflineMemberRenewOverride() {
123 $this->open($this->sboxPath
);
124 $this->webtestLogin();
126 // add membership type
127 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
129 $firstName = substr(sha1(rand()), 0, 7);
130 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
131 $contactName = "$firstName Memberson";
133 // click through to the membership tab
134 $this->click('css=li#tab_member a');
136 $this->waitForElementPresent('link=Add Membership');
137 $this->click('link=Add Membership');
139 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
141 // fill in Membership Organization and Type
142 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
143 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
146 $sourceText = 'Offline Membership Renewal Webtest';
147 $this->type('source', $sourceText);
149 // Let Join Date stay default
151 // fill in Start Date
152 $this->webtestFillDate('start_date');
154 // Let End Date be auto computed
156 // fill in Status Override?
157 $this->click('is_override', 'value=1');
158 $this->waitForElementPresent('status_id');
159 $this->select('status_id', 'value=3');
161 // fill in Record Membership Payment?
162 $this->click('record_contribution', 'value=1');
163 $this->waitForElementPresent('contribution_status_id');
165 // select the financial type for the selected membership type
166 $this->select('financial_type_id', 'value=2');
168 // the amount for the selected membership type
169 $this->type('total_amount', '100.00');
171 // select payment instrument type = Check and enter chk number
172 $this->select("payment_instrument_id", "value=4");
173 $this->waitForElementPresent("check_number");
174 $this->type("check_number", "check #12345");
175 $this->type("trxn_id", "P5476785" . rand(100, 10000));
177 // fill the payment status be default
178 $this->select("contribution_status_id", "value=2");
181 $this->click('_qf_Membership_upload-bottom');
182 $this->waitForPageToLoad($this->getTimeoutMsec());
185 $this->waitForTextPresent($sourceText);
187 // Is status message correct?
188 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
189 "Status message didn't show up after saving!"
192 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
194 // click through to the Membership Renewal Link
195 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
197 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
199 // save the renewed membership
200 $this->click('_qf_MembershipRenewal_upload-bottom');
202 $this->waitForPageToLoad($this->getTimeoutMsec());
205 $this->waitForTextPresent($sourceText);
207 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
209 // click through to the membership view screen
210 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
212 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
214 $joinDate = date('F jS, Y');
215 $startDate = date('F jS, Y', strtotime("+1 month"));
216 $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day"));
218 // verify membership renew override
219 $verifyMembershipRenewOverrideData = array(
220 'Member' => $contactName,
221 'Membership Type' => $membershipTypes['membership_type'],
223 'Source' => $sourceText,
224 'Member Since' => $joinDate,
225 'Start date' => $startDate,
226 'End date' => $endDate,
228 $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
231 function testOfflineMembershipRenewChangeType() {
232 $this->open($this->sboxPath
);
233 $this->webtestLogin();
235 // make sure period is correct for the membership type we testing for,
236 // since it might have been modified by other tests
237 // add membership type
238 $membershipTypes = $this->webtestAddMembershipType('rolling', 1);
239 $newMembershipType = $this->webtestAddMembershipType('rolling', 1);
241 $firstName = substr(sha1(rand()), 0, 7);
242 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
243 $contactName = "$firstName Memberson";
245 // click through to the membership tab
246 $this->click('css=li#tab_member a');
248 $this->waitForElementPresent('link=Add Membership');
249 $this->click('link=Add Membership');
251 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
253 // fill in Membership Organization and Type
254 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
255 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
258 $sourceText = 'Offline Membership Renewal Webtest';
259 $this->type('source', $sourceText);
262 $this->webtestFillDate('join_date', '-2 year');
264 // Let Start Date and End Date be auto computed
265 // added sleep to make sure jscript onchange for total_amount has a chance to fire
269 $this->click('_qf_Membership_upload-bottom');
270 $this->waitForPageToLoad($this->getTimeoutMsec());
273 $this->waitForTextPresent($sourceText);
275 // Is status message correct?
276 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
277 "Status message didn't show up after saving!"
280 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
282 // click through to the Membership Renewal Link
283 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
285 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
287 //change membership type
288 $this->click("changeMembershipOrgType");
289 $this->waitForElementPresent('membership_type_id[1]');
290 $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}");
291 $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}");
293 $this->click('membership_type_id[0]');
296 // save the renewed membership
297 $this->click('_qf_MembershipRenewal_upload-bottom');
299 $this->waitForPageToLoad($this->getTimeoutMsec());
302 $this->waitForTextPresent($sourceText);
304 $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
306 // click through to the membership view screen
307 $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
309 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
311 $joinDate = date('F jS, Y', strtotime("-2 year"));
312 $startDate = date('F jS, Y');
313 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
315 // verify membership renewed and the membership type is changed
316 $verifyMembershipData = array(
317 'Member' => $contactName,
318 'Membership Type' => $newMembershipType['membership_type'],
319 'Status' => 'Current',
320 'Source' => $sourceText,
321 'Member Since' => $joinDate,
322 'Start date' => $startDate,
323 'End date' => $endDate,
325 $this->webtestVerifyTabularData($verifyMembershipData);
328 function testOfflineMembershipRenewMultipleTerms() {
329 $this->open($this->sboxPath
);
330 $this->webtestLogin();
332 // make sure period is correct for the membership type we testing for,
333 // since it might have been modified by other tests
334 // add membership type
335 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
337 // quick create a contact
338 $firstName = substr(sha1(rand()), 0, 7);
339 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
340 $contactName = "$firstName Memberson";
342 // click through to the membership tab
343 $this->click('css=li#tab_member a');
345 $this->waitForElementPresent('link=Add Membership');
346 $this->click('link=Add Membership');
348 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
350 // fill in Membership Organization and Type
351 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
352 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
355 $sourceText = 'Offline Membership Renewal Webtest';
356 $this->type('source', $sourceText);
359 $this->webtestFillDate('join_date', '-2 year');
361 // Let Start Date and End Date be auto computed
363 // Record contribution
364 $this->click('record_contribution');
365 $this->waitForElementPresent( 'financial_type_id' );
366 $this->select( 'financial_type_id', "label=Member Dues" );
367 $this->select('payment_instrument_id', "label=Check");
368 $this->waitForElementPresent('check_number');
369 $this->type('check_number', '1023');
370 $this->select('contribution_status_id', "label=Completed");
371 $this->click('send_receipt');
372 // added sleep to make sure jscript onchange for total_amount has a chance to fire
376 $this->click('_qf_Membership_upload-bottom');
377 $this->waitForPageToLoad($this->getTimeoutMsec());
380 $this->waitForTextPresent($sourceText);
382 // Is status message correct?
383 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
384 "Status message didn't show up after saving!"
386 $this->assertElementContainsText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com.",
387 "Email sent to member message didn't show up after saving membership!"
390 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
392 // click through to the Membership Renewal Link
393 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
395 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
396 // Record contribution and set number of terms to 2
397 $this->click('record_contribution');
398 $this->waitForElementPresent('financial_type_id');
399 $this->click('changeTermsLink');
400 $this->waitForElementPresent('num_terms');
401 $this->type('num_terms', '');
402 $this->type('num_terms', '2');
403 // added sleep to make sure jscript 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);