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_OnlineAutoRenewMembershipTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testOnlineAutoRenewMembershipAnonymous() {
36 //configure membership signup page.
37 $pageId = $this->_configureMembershipPage();
39 //now do the test membership signup.
40 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
42 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
44 $this->click("auto_renew");
46 $this->webtestAddCreditCardDetails();
48 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
50 $this->type('email-5', "{$lastName}@example.com");
52 $this->click("_qf_Main_upload-bottom");
53 $this->waitForPageToLoad($this->getTimeoutMsec());
54 $this->waitForElementPresent("_qf_Confirm_next-bottom");
56 $text = 'I want this membership to be renewed automatically every 1 year(s).';
57 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
59 $this->click("_qf_Confirm_next-bottom");
60 $this->waitForPageToLoad($this->getTimeoutMsec());
62 $text = 'This membership will be renewed automatically every 1 year(s).';
63 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
66 function testOnlineAutoRenewMembershipAuthenticated() {
67 //configure membership signup page.
68 $pageId = $this->_configureMembershipPage();
70 $this->open($this->sboxPath
);
71 $this->webtestLogin();
72 $this->waitForPageToLoad($this->getTimeoutMsec());
74 //now do the test membership signup.
75 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
77 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
79 $this->click("auto_renew");
81 $this->webtestAddCreditCardDetails();
83 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
85 $this->type('email-5', "{$lastName}@example.com");
87 $this->click("_qf_Main_upload-bottom");
88 $this->waitForElementPresent("_qf_Confirm_next-bottom");
90 $text = 'I want this membership to be renewed automatically every 1 year(s).';
91 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
93 $this->click("_qf_Confirm_next-bottom");
94 $this->waitForPageToLoad($this->getTimeoutMsec());
96 $text = 'This membership will be renewed automatically every 1 year(s).';
97 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
100 function testOnlinePendingAutoRenewMembershipAnonymous() {
101 //configure membership signup page.
102 $pageId = $this->_configureMembershipPage();
104 //now do the test membership signup.
105 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
107 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
109 $this->click("auto_renew");
111 $this->webtestAddCreditCardDetails();
112 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
113 $this->type('email-5', "{$lastName}@example.com");
115 $this->click("_qf_Main_upload-bottom");
116 $this->waitForElementPresent("_qf_Confirm_next-bottom");
118 $text = 'I want this membership to be renewed automatically every 1 year(s).';
119 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
121 $this->click("_qf_Confirm_next-bottom");
122 $this->waitForPageToLoad($this->getTimeoutMsec());
124 $text = 'This membership will be renewed automatically every 1 year(s).';
125 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
128 function _configureMembershipPage() {
129 static $pageId = NULL;
132 $this->open($this->sboxPath
);
133 $this->webtestLogin();
135 //add payment processor.
136 $hash = substr(sha1(rand()), 0, 7);
137 $rand = 2 * rand(2, 50);
138 $processorName = "Webtest Auto Renew AuthNet" . $hash;
139 $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
141 // -- start updating membership types
142 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom");
144 $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')]");
146 $this->type("duration_interval", "1");
147 $this->select("duration_unit", "label=year");
149 //wait for the auto-complete member_of_contact to populate
152 $this->click("_qf_MembershipType_upload-bottom");
153 $this->waitForPageToLoad($this->getTimeoutMsec());
155 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom");
157 $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')]");
159 $this->type("duration_interval", "1");
160 $this->select("duration_unit", "label=year");
162 //wait for the auto-complete member_of_contact to populate
165 $this->click("_qf_MembershipType_upload-bottom");
166 $this->waitForPageToLoad($this->getTimeoutMsec());
169 // create contribution page with randomized title and default params
170 $amountSection = FALSE;
175 $membershipTypes = array(array('id' => 1, 'auto_renew' => 1),
176 array('id' => 2, 'auto_renew' => 1),
178 $memPriceSetId = NULL;
180 $profilePreId = NULL;
181 $profilePostId = NULL;
186 $contributionTitle = "Title $hash";
187 $pageId = $this->webtestAddContributionPage($hash,
190 array($processorName => 'AuthNet'),
207 //make sure we do have required permissions.
208 $permissions = array("edit-1-make-online-contributions");
209 $this->changePermissions($permissions);
211 // now logout and do membership test that way
212 $this->openCiviPage('logout', 'reset=1', NULL);