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
69 // Because it tends to cause problems, all uses of sleep() must be justified in comments
70 // Sleep should never be used for wait for anything to load from the server
71 // Justification for this instance: make sure onchange for total_amount has a chance to fire
75 $this->click('_qf_Membership_upload-bottom');
76 $this->waitForPageToLoad($this->getTimeoutMsec());
79 $this->waitForTextPresent($sourceText);
81 // Is status message correct?
82 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
83 "Status message didn't show up after saving!"
86 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
88 // click through to the Membership Renewal Link
89 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
91 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
93 // save the renewed membership
94 $this->click('_qf_MembershipRenewal_upload-bottom');
96 $this->waitForPageToLoad($this->getTimeoutMsec());
99 $this->waitForTextPresent($sourceText);
101 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
103 // click through to the membership view screen
104 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
106 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
108 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
109 $endDate = date('F jS, Y', strtotime("+2 year -1 day"));
111 // verify membership renewed
112 $verifyMembershipRenewData = array(
113 'Member' => $contactName,
114 'Membership Type' => $membershipTypes['membership_type'],
115 'Status' => 'Current',
116 'Source' => $sourceText,
117 'Member Since' => $joinDate,
118 'Start date' => $startDate,
119 'End date' => $endDate,
121 $this->webtestVerifyTabularData($verifyMembershipRenewData);
124 function testOfflineMemberRenewOverride() {
125 $this->webtestLogin();
127 // add membership type
128 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
130 $firstName = substr(sha1(rand()), 0, 7);
131 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
132 $contactName = "$firstName Memberson";
134 // click through to the membership tab
135 $this->click('css=li#tab_member a');
137 $this->waitForElementPresent('link=Add Membership');
138 $this->click('link=Add Membership');
140 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
142 // fill in Membership Organization and Type
143 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
144 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
147 $sourceText = 'Offline Membership Renewal Webtest';
148 $this->type('source', $sourceText);
150 // Let Join Date stay default
152 // fill in Start Date
153 $this->webtestFillDate('start_date');
155 // Let End Date be auto computed
157 // fill in Status Override?
158 $this->click('is_override', 'value=1');
159 $this->waitForElementPresent('status_id');
160 $this->select('status_id', 'value=3');
162 // fill in Record Membership Payment?
163 $this->click('record_contribution', 'value=1');
164 $this->waitForElementPresent('contribution_status_id');
166 // select the financial type for the selected membership type
167 $this->select('financial_type_id', 'value=2');
169 // the amount for the selected membership type
170 $this->type('total_amount', '100.00');
172 // select payment instrument type = Check and enter chk number
173 $this->select("payment_instrument_id", "value=4");
174 $this->waitForElementPresent("check_number");
175 $this->type("check_number", "check #12345");
176 $this->type("trxn_id", "P5476785" . rand(100, 10000));
178 // fill the payment status be default
179 $this->select("contribution_status_id", "value=2");
182 $this->click('_qf_Membership_upload-bottom');
183 $this->waitForPageToLoad($this->getTimeoutMsec());
186 $this->waitForTextPresent($sourceText);
188 // Is status message correct?
189 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
190 "Status message didn't show up after saving!"
193 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
195 // click through to the Membership Renewal Link
196 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
198 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
200 // save the renewed membership
201 $this->click('_qf_MembershipRenewal_upload-bottom');
203 $this->waitForPageToLoad($this->getTimeoutMsec());
206 $this->waitForTextPresent($sourceText);
208 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
210 // click through to the membership view screen
211 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
213 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
215 $joinDate = date('F jS, Y');
216 $startDate = date('F jS, Y', strtotime("+1 month"));
217 $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day"));
219 // verify membership renew override
220 $verifyMembershipRenewOverrideData = array(
221 'Member' => $contactName,
222 'Membership Type' => $membershipTypes['membership_type'],
224 'Source' => $sourceText,
225 'Member Since' => $joinDate,
226 'Start date' => $startDate,
227 'End date' => $endDate,
229 $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
232 function testOfflineMembershipRenewChangeType() {
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
266 // Because it tends to cause problems, all uses of sleep() must be justified in comments
267 // Sleep should never be used for wait for anything to load from the server
268 // Justification for this instance: make sure onchange for total_amount has a chance to fire
272 $this->click('_qf_Membership_upload-bottom');
273 $this->waitForPageToLoad($this->getTimeoutMsec());
276 $this->waitForTextPresent($sourceText);
278 // Is status message correct?
279 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
280 "Status message didn't show up after saving!"
283 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
285 // click through to the Membership Renewal Link
286 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
288 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
290 //change membership type
291 $this->click("changeMembershipOrgType");
292 $this->waitForElementPresent('membership_type_id[1]');
293 $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}");
294 $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}");
296 $this->click('membership_type_id[0]');
297 // Because it tends to cause problems, all uses of sleep() must be justified in comments
298 // Sleep should never be used for wait for anything to load from the server
299 // Justification for this instance: wait for onchange handler
302 // save the renewed membership
303 $this->click('_qf_MembershipRenewal_upload-bottom');
305 $this->waitForPageToLoad($this->getTimeoutMsec());
308 $this->waitForTextPresent($sourceText);
310 $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
312 // click through to the membership view screen
313 $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
315 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
317 $joinDate = date('F jS, Y', strtotime("-2 year"));
318 $startDate = date('F jS, Y');
319 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
321 // verify membership renewed and the membership type is changed
322 $verifyMembershipData = array(
323 'Member' => $contactName,
324 'Membership Type' => $newMembershipType['membership_type'],
325 'Status' => 'Current',
326 'Source' => $sourceText,
327 'Member Since' => $joinDate,
328 'Start date' => $startDate,
329 'End date' => $endDate,
331 $this->webtestVerifyTabularData($verifyMembershipData);
334 function testOfflineMembershipRenewMultipleTerms() {
335 $this->webtestLogin();
337 // make sure period is correct for the membership type we testing for,
338 // since it might have been modified by other tests
339 // add membership type
340 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
342 // quick create a contact
343 $firstName = substr(sha1(rand()), 0, 7);
344 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
345 $contactName = "$firstName Memberson";
347 // click through to the membership tab
348 $this->click('css=li#tab_member a');
350 $this->waitForElementPresent('link=Add Membership');
351 $this->click('link=Add Membership');
353 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
355 // fill in Membership Organization and Type
356 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
357 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
360 $sourceText = 'Offline Membership Renewal Webtest';
361 $this->type('source', $sourceText);
364 $this->webtestFillDate('join_date', '-2 year');
366 // Let Start Date and End Date be auto computed
368 // Record contribution
369 $this->click('record_contribution');
370 $this->waitForElementPresent( 'financial_type_id' );
371 $this->select( 'financial_type_id', "label=Member Dues" );
372 $this->select('payment_instrument_id', "label=Check");
373 $this->waitForElementPresent('check_number');
374 $this->type('check_number', '1023');
375 $this->select('contribution_status_id', "label=Completed");
376 $this->click('send_receipt');
378 // Because it tends to cause problems, all uses of sleep() must be justified in comments
379 // Sleep should never be used for wait for anything to load from the server
380 // Justification for this instance: make sure onchange for total_amount has a chance to fire
384 $this->click('_qf_Membership_upload-bottom');
385 $this->waitForPageToLoad($this->getTimeoutMsec());
388 $this->waitForTextPresent($sourceText);
390 // Is status message correct?
391 $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.",
392 "Status message didn't show up after saving!"
394 $this->assertElementContainsText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com.",
395 "Email sent to member message didn't show up after saving membership!"
398 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
400 // click through to the Membership Renewal Link
401 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
403 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
404 // Record contribution and set number of terms to 2
405 $this->click('record_contribution');
406 $this->waitForElementPresent('financial_type_id');
407 $this->click('changeTermsLink');
408 $this->waitForElementPresent('num_terms');
409 $this->type('num_terms', '');
410 $this->type('num_terms', '2');
412 // Because it tends to cause problems, all uses of sleep() must be justified in comments
413 // Sleep should never be used for wait for anything to load from the server
414 // Justification for this instance: make sure onchange for total_amount has a chance to fire
416 $this->click('total_amount');
417 $this->verifyValue('total_amount', "200.00");
418 $this->select('financial_type_id', "label=Member Dues");
419 $this->select('payment_instrument_id', "label=Check");
420 $this->waitForElementPresent('check_number');
421 $this->type('check_number', '1024');
422 $this->select('contribution_status_id', "label=Completed");
423 $this->click('send_receipt');
425 // save the renewed membership
426 $this->click('_qf_MembershipRenewal_upload-bottom');
428 $this->waitForPageToLoad($this->getTimeoutMsec());
431 $this->waitForTextPresent($sourceText);
433 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
435 // click through to the membership view screen
436 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
438 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
440 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
441 // Adding 2 x 2 years renewal to initial membership.
442 $endDate = date('F jS, Y', strtotime("+4 year -1 day"));
444 // verify membership renewed
445 $verifyMembershipRenewData = array(
446 'Member' => $contactName,
447 'Membership Type' => $membershipTypes['membership_type'],
448 'Status' => 'Current',
449 'Source' => $sourceText,
450 'Member Since' => $joinDate,
451 'Start date' => $startDate,
452 'End date' => $endDate,
454 $this->webtestVerifyTabularData($verifyMembershipRenewData);