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->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
54 $text = 'I want this membership to be renewed automatically every 1 year(s).';
55 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
57 $this->click("_qf_Confirm_next-bottom");
58 $this->waitForPageToLoad($this->getTimeoutMsec());
60 $text = 'This membership will be renewed automatically every 1 year(s).';
61 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
64 function testOnlineAutoRenewMembershipAuthenticated() {
65 //configure membership signup page.
66 $pageId = $this->_configureMembershipPage();
68 $this->webtestLogin();
69 $this->waitForPageToLoad($this->getTimeoutMsec());
71 //now do the test membership signup.
72 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
74 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
76 $this->click("auto_renew");
78 $this->webtestAddCreditCardDetails();
80 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
82 $this->type('email-5', "{$lastName}@example.com");
84 $this->click("_qf_Main_upload-bottom");
85 $this->waitForElementPresent("_qf_Confirm_next-bottom");
87 $text = 'I want this membership to be renewed automatically every 1 year(s).';
88 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
90 $this->click("_qf_Confirm_next-bottom");
91 $this->waitForPageToLoad($this->getTimeoutMsec());
93 $text = 'This membership will be renewed automatically every 1 year(s).';
94 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
97 function testOnlinePendingAutoRenewMembershipAnonymous() {
98 //configure membership signup page.
99 $pageId = $this->_configureMembershipPage();
101 //now do the test membership signup.
102 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
104 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
106 $this->click("auto_renew");
108 $this->webtestAddCreditCardDetails();
109 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
110 $this->type('email-5', "{$lastName}@example.com");
112 $this->click("_qf_Main_upload-bottom");
113 $this->waitForElementPresent("_qf_Confirm_next-bottom");
115 $text = 'I want this membership to be renewed automatically every 1 year(s).';
116 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
118 $this->click("_qf_Confirm_next-bottom");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
121 $text = 'This membership will be renewed automatically every 1 year(s).';
122 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
125 function _configureMembershipPage() {
126 static $pageId = NULL;
129 $this->webtestLogin();
131 //add payment processor.
132 $hash = substr(sha1(rand()), 0, 7);
133 $rand = 2 * rand(2, 50);
134 $processorName = "Webtest Auto Renew AuthNet" . $hash;
135 $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
137 // -- start updating membership types
138 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom");
140 $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')]");
142 $this->type("duration_interval", "1");
143 $this->select("duration_unit", "label=year");
145 // wait for the auto-complete member_of_contact to populate
146 $this->waitForValue('member_of_contact', '::');
148 $this->click("_qf_MembershipType_upload-bottom");
149 $this->waitForPageToLoad($this->getTimeoutMsec());
151 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom");
153 $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')]");
155 $this->type("duration_interval", "1");
156 $this->select("duration_unit", "label=year");
158 //wait for the auto-complete member_of_contact to populate
159 $this->waitForValue('member_of_contact', '::');
161 $this->click("_qf_MembershipType_upload-bottom");
162 $this->waitForPageToLoad($this->getTimeoutMsec());
164 // create contribution page with randomized title and default params
165 $amountSection = FALSE;
170 $membershipTypes = array(array('id' => 1, 'auto_renew' => 1),
171 array('id' => 2, 'auto_renew' => 1),
173 $memPriceSetId = NULL;
175 $profilePreId = NULL;
176 $profilePostId = NULL;
181 $contributionTitle = "Title $hash";
182 $pageId = $this->webtestAddContributionPage($hash,
185 array($processorName => 'AuthNet'),
202 //make sure we do have required permissions.
203 $permissions = array("edit-1-make-online-contributions");
204 $this->changePermissions($permissions);
206 // now logout and do membership test that way
207 $this->webtestLogout();