3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 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
78 $this->click('_qf_Membership_upload-bottom');
79 $this->waitForPageToLoad($this->getTimeoutMsec());
82 $this->waitForTextPresent($sourceText);
84 // Is status message correct?
85 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
87 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
89 // click through to the Membership Renewal Link
90 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
92 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
94 // save the renewed membership
95 $this->click('_qf_MembershipRenewal_upload-bottom');
97 $this->waitForPageToLoad($this->getTimeoutMsec());
100 $this->waitForTextPresent($sourceText);
102 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
104 // click through to the membership view screen
105 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
107 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
109 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
110 $endDate = date('F jS, Y', strtotime("+2 year -1 day"));
112 // verify membership renewed
113 $verifyMembershipRenewData = array(
114 'Member' => $contactName,
115 'Membership Type' => $membershipTypes['membership_type'],
116 'Status' => 'Current',
117 'Source' => $sourceText,
118 'Member Since' => $joinDate,
119 'Start date' => $startDate,
120 'End date' => $endDate,
122 $this->webtestVerifyTabularData($verifyMembershipRenewData);
125 function testOfflineMemberRenewOverride() {
126 $this->webtestLogin();
128 // add membership type
129 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
131 $firstName = substr(sha1(rand()), 0, 7);
132 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
133 $contactName = "$firstName Memberson";
135 // click through to the membership tab
136 $this->click('css=li#tab_member a');
138 $this->waitForElementPresent('link=Add Membership');
139 $this->click('link=Add Membership');
141 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
143 // fill in Membership Organization and Type
144 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
145 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
148 $sourceText = 'Offline Membership Renewal Webtest';
149 $this->type('source', $sourceText);
151 // Let Join Date stay default
153 // fill in Start Date
154 $this->webtestFillDate('start_date');
156 // Let End Date be auto computed
158 // fill in Status Override?
159 $this->click('is_override', 'value=1');
160 $this->waitForElementPresent('status_id');
161 $this->select('status_id', 'value=3');
163 // fill in Record Membership Payment?
164 $this->click('record_contribution', 'value=1');
165 $this->waitForElementPresent('contribution_status_id');
167 // select the financial type for the selected membership type
168 $this->select('financial_type_id', 'value=2');
170 // the amount for the selected membership type
171 $this->type('total_amount', '100.00');
173 // select payment instrument type = Check and enter chk number
174 $this->select("payment_instrument_id", "value=4");
175 $this->waitForElementPresent("check_number");
176 $this->type("check_number", "check #12345");
177 $this->type("trxn_id", "P5476785" . rand(100, 10000));
179 // fill the payment status be default
180 $this->select("contribution_status_id", "value=2");
183 $this->click('_qf_Membership_upload-bottom');
184 $this->waitForPageToLoad($this->getTimeoutMsec());
187 $this->waitForTextPresent($sourceText);
189 // Is status message correct?
190 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
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->webtestLogin();
234 // make sure period is correct for the membership type we testing for,
235 // since it might have been modified by other tests
236 // add membership type
237 $membershipTypes = $this->webtestAddMembershipType('rolling', 1);
238 $newMembershipType = $this->webtestAddMembershipType('rolling', 1);
240 $firstName = substr(sha1(rand()), 0, 7);
241 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
242 $contactName = "$firstName Memberson";
244 // click through to the membership tab
245 $this->click('css=li#tab_member a');
247 $this->waitForElementPresent('link=Add Membership');
248 $this->click('link=Add Membership');
250 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
252 // fill in Membership Organization and Type
253 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
254 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
257 $sourceText = 'Offline Membership Renewal Webtest';
258 $this->type('source', $sourceText);
261 $this->webtestFillDate('join_date', '-2 year');
263 // Let Start Date and End Date be auto computed
265 // Because it tends to cause problems, all uses of sleep() must be justified in comments
266 // Sleep should never be used for wait for anything to load from the server
267 // Justification for this instance: make sure onchange for total_amount has a chance to fire
271 $this->click('_qf_Membership_upload-bottom');
272 $this->waitForPageToLoad($this->getTimeoutMsec());
275 $this->waitForTextPresent($sourceText);
277 // Is status message correct?
278 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
280 $this->waitForElementPresent("xpath=//div[@id='inactive-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='inactive-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]');
294 // Because it tends to cause problems, all uses of sleep() must be justified in comments
295 // Sleep should never be used for wait for anything to load from the server
296 // Justification for this instance: wait for onchange handler
299 // save the renewed membership
300 $this->click('_qf_MembershipRenewal_upload-bottom');
304 $this->waitForTextPresent($sourceText);
306 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
308 // click through to the membership view screen
309 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
311 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
313 $joinDate = date('F jS, Y', strtotime("-2 year"));
314 $startDate = date('F jS, Y');
315 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
317 // verify membership renewed and the membership type is changed
318 $verifyMembershipData = array(
319 'Member' => $contactName,
320 'Membership Type' => $newMembershipType['membership_type'],
321 'Status' => 'Current',
322 'Source' => $sourceText,
323 'Member Since' => $joinDate,
324 'Start date' => $startDate,
325 'End date' => $endDate,
327 $this->webtestVerifyTabularData($verifyMembershipData);
330 function testOfflineMembershipRenewMultipleTerms() {
331 $this->webtestLogin();
333 // make sure period is correct for the membership type we testing for,
334 // since it might have been modified by other tests
335 // add membership type
336 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
338 // quick create a contact
339 $firstName = substr(sha1(rand()), 0, 7);
340 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
341 $contactName = "$firstName Memberson";
343 // click through to the membership tab
344 $this->click('css=li#tab_member a');
346 $this->waitForElementPresent('link=Add Membership');
347 $this->click('link=Add Membership');
349 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
351 // fill in Membership Organization and Type
352 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
353 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
356 $sourceText = 'Offline Membership Renewal Webtest';
357 $this->type('source', $sourceText);
360 $this->webtestFillDate('join_date', '-2 year');
362 // Let Start Date and End Date be auto computed
364 // Record contribution
365 $this->click('record_contribution');
366 $this->waitForElementPresent( 'financial_type_id' );
367 $this->select( 'financial_type_id', "label=Member Dues" );
368 $this->select('payment_instrument_id', "label=Check");
369 $this->waitForElementPresent('check_number');
370 $this->type('check_number', '1023');
371 $this->select('contribution_status_id', "label=Completed");
372 $this->click('send_receipt');
374 // Because it tends to cause problems, all uses of sleep() must be justified in comments
375 // Sleep should never be used for wait for anything to load from the server
376 // Justification for this instance: make sure onchange for total_amount has a chance to fire
380 $this->click('_qf_Membership_upload-bottom');
381 $this->waitForPageToLoad($this->getTimeoutMsec());
384 $this->waitForTextPresent($sourceText);
386 // Is status message correct?
387 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
388 $this->waitForText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com.");
391 $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');
404 // Because it tends to cause problems, all uses of sleep() must be justified in comments
405 // Sleep should never be used for wait for anything to load from the server
406 // Justification for this instance: make sure onchange for total_amount has a chance to fire
408 $this->click('total_amount');
409 $this->verifyValue('total_amount', "200.00");
410 $this->select('financial_type_id', "label=Member Dues");
411 $this->select('payment_instrument_id', "label=Check");
412 $this->waitForElementPresent('check_number');
413 $this->type('check_number', '1024');
414 $this->select('contribution_status_id', "label=Completed");
415 $this->click('send_receipt');
417 // save the renewed membership
418 $this->click('_qf_MembershipRenewal_upload-bottom');
422 $this->waitForTextPresent($sourceText);
424 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
426 // click through to the membership view screen
427 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
429 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
431 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
432 // Adding 2 x 2 years renewal to initial membership.
433 $endDate = date('F jS, Y', strtotime("+4 year -1 day"));
435 // verify membership renewed
436 $verifyMembershipRenewData = array(
437 'Member' => $contactName,
438 'Membership Type' => $membershipTypes['membership_type'],
439 'Status' => 'Current',
440 'Source' => $sourceText,
441 'Member Since' => $joinDate,
442 'Start date' => $startDate,
443 'End date' => $endDate,
445 $this->webtestVerifyTabularData($verifyMembershipRenewData);