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');
165 $this->waitForAjaxContent();
167 // the amount for the selected membership type
168 $this->type('total_amount', '100.00');
170 // select payment instrument type = Check and enter chk number
171 $this->select("payment_instrument_id", "value=4");
172 $this->waitForElementPresent("check_number");
173 $this->type("check_number", "check #12345");
174 $this->type("trxn_id", "P5476785" . rand(100, 10000));
176 // fill the payment status be default
177 $this->select("contribution_status_id", "value=2");
180 $this->click('_qf_Membership_upload-bottom');
183 $this->waitForTextPresent($sourceText);
185 // Is status message correct?
186 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
188 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']");
190 // click through to the Membership Renewal Link
191 $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']");
193 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
195 // save the renewed membership
196 $this->click('_qf_MembershipRenewal_upload-bottom');
199 $this->waitForAjaxContent();
201 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]");
203 // click through to the membership view screen
204 $this->waitForAjaxContent();
205 $this->click("xpath=//div[@id='memberships']/div/table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]");
206 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
208 $joinDate = date('F jS, Y');
209 $startDate = date('F jS, Y', strtotime("+1 month"));
210 $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day"));
212 // verify membership renew override
213 $verifyMembershipRenewOverrideData = array(
214 'Member' => $contactName,
215 'Membership Type' => $membershipTypes['membership_type'],
217 'Source' => $sourceText,
218 'Member Since' => $joinDate,
219 'Start date' => $startDate,
220 'End date' => $endDate,
222 $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
225 public function testOfflineMembershipRenewChangeType() {
226 $this->webtestLogin();
228 // make sure period is correct for the membership type we testing for,
229 // since it might have been modified by other tests
230 // add membership type
231 $membershipTypes = $this->webtestAddMembershipType('rolling', 1);
232 $newMembershipType = $this->webtestAddMembershipType('rolling', 1);
234 $firstName = substr(sha1(rand()), 0, 7);
235 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
236 $contactName = "$firstName Memberson";
238 // click through to the membership tab
239 $this->click('css=li#tab_member a');
241 $this->waitForElementPresent('link=Add Membership');
242 $this->click('link=Add Membership');
244 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
246 // fill in Membership Organization and Type
247 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
248 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
251 $sourceText = 'Offline Membership Renewal Webtest';
252 $this->type('source', $sourceText);
255 $this->webtestFillDate('join_date', '-2 year');
257 // Let Start Date and End Date be auto computed
259 // Because it tends to cause problems, all uses of sleep() must be justified in comments
260 // Sleep should never be used for wait for anything to load from the server
261 // Justification for this instance: make sure onchange for total_amount has a chance to fire
262 $this->waitForAjaxContent();
265 $this->click('_qf_Membership_upload-bottom');
268 $this->waitForTextPresent($sourceText);
270 // Is status message correct?
271 $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
273 $this->waitForElementPresent("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
275 // click through to the Membership Renewal Link
276 $this->click("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
278 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
280 //change membership type
281 $this->click("changeMembershipOrgType");
282 $this->waitForElementPresent('membership_type_id[1]');
283 $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}");
284 $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}");
286 $this->click('membership_type_id[0]');
287 // Because it tends to cause problems, all uses of sleep() must be justified in comments
288 // Sleep should never be used for wait for anything to load from the server
289 // Justification for this instance: wait for onchange handler
290 $this->waitForAjaxContent();
292 // save the renewed membership
293 $this->click('_qf_MembershipRenewal_upload-bottom');
296 $this->waitForTextPresent($sourceText);
298 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
300 // click through to the membership view screen
301 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
303 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
305 $joinDate = date('F jS, Y', strtotime("-2 year"));
306 $startDate = date('F jS, Y');
307 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
309 // verify membership renewed and the membership type is changed
310 $verifyMembershipData = array(
311 'Member' => $contactName,
312 'Membership Type' => $newMembershipType['membership_type'],
313 'Status' => 'Current',
314 'Source' => $sourceText,
315 'Member Since' => $joinDate,
316 'Start date' => $startDate,
317 'End date' => $endDate,
319 $this->webtestVerifyTabularData($verifyMembershipData);
322 public function testOfflineMembershipRenewMultipleTerms() {
323 $this->webtestLogin();
325 // make sure period is correct for the membership type we testing for,
326 // since it might have been modified by other tests
327 // add membership type
328 $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
330 // quick create a contact
331 $firstName = substr(sha1(rand()), 0, 7);
332 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
333 $contactName = "$firstName Memberson";
335 // click through to the membership tab
336 $this->click('css=li#tab_member a');
338 $this->waitForElementPresent('link=Add Membership');
339 $this->click('link=Add Membership');
341 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
343 // fill in Membership Organization and Type
344 $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
345 $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
348 $sourceText = 'Offline Membership Renewal Webtest';
349 $this->type('source', $sourceText);
352 $this->webtestFillDate('join_date', '-2 year');
354 // Let Start Date and End Date be auto computed
356 // Record contribution
357 $this->waitForElementPresent('financial_type_id');
358 $this->select('financial_type_id', "label=Member Dues");
359 $this->select('payment_instrument_id', "label=Check");
360 $this->waitForElementPresent('check_number');
361 $this->type('check_number', '1023');
362 $this->select('contribution_status_id', "label=Completed");
363 $this->click('send_receipt');
365 $this->waitForElementPresent('_qf_Membership_upload-bottom');
368 $this->click('_qf_Membership_upload-bottom');
371 $this->waitForTextPresent($sourceText);
372 $endDate = $this->getText("xpath=//div[@id='memberships']//table/tbody/tr/td[4]");
374 // Is status message correct?
375 $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.");
377 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
378 // click through to the Membership Renewal Link
379 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
381 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
382 // Record contribution and set number of terms to 2
383 $this->click('record_contribution');
384 $this->waitForElementPresent('financial_type_id');
385 $this->click('changeTermsLink');
386 $this->waitForElementPresent('num_terms');
387 $this->type('num_terms', '');
388 $this->type('num_terms', '2');
389 $this->waitForElementPresent('total_amount');
390 $this->click('total_amount');
391 $this->verifyValue('total_amount', "200.00");
392 $this->select('financial_type_id', "label=Member Dues");
393 $this->select('payment_instrument_id', "label=Check");
394 $this->waitForElementPresent('check_number');
395 $this->type('check_number', '1024');
396 $this->select('contribution_status_id', "label=Completed");
397 $this->click('send_receipt');
399 // save the renewed membership
400 $this->click('_qf_MembershipRenewal_upload-bottom');
403 $this->waitForTextPresent($sourceText);
405 $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
407 // click through to the membership view screen
408 $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
410 $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
412 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
413 // Adding 2 x 2 years renewal to initial membership.
414 $endDate = date('F jS, Y', strtotime("+4 year -1 day"));
416 // verify membership renewed
417 $verifyMembershipRenewData = array(
418 'Member' => $contactName,
419 'Membership Type' => $membershipTypes['membership_type'],
420 'Status' => 'Current',
421 'Source' => $sourceText,
422 'Member Since' => $joinDate,
423 'Start date' => $startDate,
424 'End date' => $endDate,
426 $this->webtestVerifyTabularData($verifyMembershipRenewData);