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->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!");
82 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
84 // click through to the Membership Renewal Link
85 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']");
87 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
89 // save the renewed membership
90 $this->click('_qf_MembershipRenewal_upload-bottom');
92 $this->waitForPageToLoad($this->getTimeoutMsec());
95 $this->waitForTextPresent($sourceText);
97 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
99 // click through to the membership view screen
100 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
102 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
104 $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
105 $endDate = date('F jS, Y', strtotime("+2 year -1 day"));
107 // verify membership renewed
108 $verifyMembershipRenewData = array(
109 'Member' => $contactName,
110 'Membership Type' => $membershipTypes['membership_type'],
111 'Status' => 'Current',
112 'Source' => $sourceText,
113 'Member Since' => $joinDate,
114 'Start date' => $startDate,
115 'End date' => $endDate,
117 foreach ($verifyMembershipRenewData as $label => $value) {
118 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
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->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "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 foreach ($verifyMembershipRenewOverrideData as $label => $value) {
227 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
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->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!");
278 $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
280 // click through to the Membership Renewal Link
281 $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']");
283 $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
285 //change membership type
286 $this->click("changeMembershipOrgType");
287 $this->waitForElementPresent('membership_type_id[1]');
288 $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}");
289 $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}");
291 $this->click('membership_type_id[0]');
294 // save the renewed membership
295 $this->click('_qf_MembershipRenewal_upload-bottom');
297 $this->waitForPageToLoad($this->getTimeoutMsec());
300 $this->waitForTextPresent($sourceText);
302 $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
304 // click through to the membership view screen
305 $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']");
307 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
309 $joinDate = date('F jS, Y', strtotime("-2 year"));
310 $startDate = date('F jS, Y');
311 $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
313 // verify membership renewed and the membership type is changed
314 $verifyMembershipData = array(
315 'Member' => $contactName,
316 'Membership Type' => $newMembershipType['membership_type'],
317 'Status' => 'Current',
318 'Source' => $sourceText,
319 'Member Since' => $joinDate,
320 'Start date' => $startDate,
321 'End date' => $endDate,
323 foreach ($verifyMembershipData as $label => $value) {
324 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
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->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!");
384 $this->assertTrue($this->isTextPresent("A membership confirmation and receipt has been sent to {$firstName}@memberson.com."), "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 foreach ($verifyMembershipRenewData as $label => $value) {
440 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));