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';
28 class WebTest_Member_OnlineAutoRenewMembershipTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testOnlineAutoRenewMembershipAnonymous() {
35 //configure membership signup page.
36 $pageId = $this->_configureMembershipPage();
38 //now do the test membership signup.
39 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
41 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
43 $this->click("auto_renew");
45 $this->webtestAddCreditCardDetails();
47 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
49 $this->type('email-5', "{$lastName}@example.com");
51 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
53 $text = 'I want this membership to be renewed automatically every 1 year(s).';
54 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text);
56 $this->click("_qf_Confirm_next-bottom");
57 $this->waitForPageToLoad($this->getTimeoutMsec());
59 $text = 'This membership will be renewed automatically every 1 year(s).';
60 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text);
63 function testOnlineAutoRenewMembershipAuthenticated() {
64 //configure membership signup page.
65 $pageId = $this->_configureMembershipPage();
67 $this->webtestLogin();
68 $this->waitForPageToLoad($this->getTimeoutMsec());
70 //now do the test membership signup.
71 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
73 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
75 $this->click("auto_renew");
77 $this->webtestAddCreditCardDetails();
79 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
81 $this->type('email-5', "{$lastName}@example.com");
83 $this->click("_qf_Main_upload-bottom");
84 $this->waitForElementPresent("_qf_Confirm_next-bottom");
86 $text = 'I want this membership to be renewed automatically every 1 year(s).';
87 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text);
89 $this->click("_qf_Confirm_next-bottom");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
92 $text = 'This membership will be renewed automatically every 1 year(s).';
93 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text);
96 function testOnlinePendingAutoRenewMembershipAnonymous() {
97 //configure membership signup page.
98 $pageId = $this->_configureMembershipPage();
100 //now do the test membership signup.
101 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
103 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
105 $this->click("auto_renew");
107 $this->webtestAddCreditCardDetails();
108 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
109 $this->type('email-5', "{$lastName}@example.com");
111 $this->click("_qf_Main_upload-bottom");
112 $this->waitForElementPresent("_qf_Confirm_next-bottom");
114 $text = 'I want this membership to be renewed automatically every 1 year(s).';
115 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text);
117 $this->click("_qf_Confirm_next-bottom");
118 $this->waitForPageToLoad($this->getTimeoutMsec());
120 $text = 'This membership will be renewed automatically every 1 year(s).';
121 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text);
124 function _configureMembershipPage() {
125 static $pageId = NULL;
128 $this->webtestLogin();
130 //add payment processor.
131 $hash = substr(sha1(rand()), 0, 7);
132 $rand = 2 * rand(2, 50);
133 $processorName = "Webtest Auto Renew AuthNet" . $hash;
134 $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
136 // -- start updating membership types
137 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom");
139 $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
141 $this->type("duration_interval", "1");
142 $this->select("duration_unit", "label=year");
145 $this->click("_qf_MembershipType_upload-bottom");
146 $this->waitForPageToLoad($this->getTimeoutMsec());
148 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom");
150 $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
152 $this->type("duration_interval", "1");
153 $this->select("duration_unit", "label=year");
156 $this->click("_qf_MembershipType_upload-bottom");
157 $this->waitForPageToLoad($this->getTimeoutMsec());
159 // create contribution page with randomized title and default params
160 $amountSection = FALSE;
165 $membershipTypes = array(array('id' => 1, 'auto_renew' => 1),
166 array('id' => 2, 'auto_renew' => 1),
168 $memPriceSetId = NULL;
170 $profilePreId = NULL;
171 $profilePostId = NULL;
176 $contributionTitle = "Title $hash";
177 $pageId = $this->webtestAddContributionPage($hash,
180 array($processorName => 'AuthNet'),
197 //make sure we do have required permissions.
198 $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
199 $this->changePermissions($permissions);
201 // now logout and do membership test that way
202 $this->webtestLogout();