3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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_OnlineAutoRenewMembershipTest
32 class WebTest_Member_OnlineAutoRenewMembershipTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testOnlineAutoRenewMembershipAnonymous() {
39 //configure membership signup page.
40 $pageId = $this->_configureMembershipPage();
42 //now do the test membership signup.
43 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
45 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
47 $this->click("auto_renew");
49 $this->webtestAddCreditCardDetails();
51 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
53 $this->type('email-5', "{$lastName}@example.com");
55 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
57 $text = 'I want this membership to be renewed automatically every 1 year(s).';
58 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $text, 'Missing text: ' . $text);
60 $this->click("_qf_Confirm_next-bottom");
61 $this->waitForPageToLoad($this->getTimeoutMsec());
63 $text = 'This membership will be renewed automatically every year.';
64 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text);
67 public function testOnlineAutoRenewMembershipAuthenticated() {
68 //configure membership signup page.
69 $pageId = $this->_configureMembershipPage();
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]/div[2]/span/label/span[1][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("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $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 year.';
97 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text);
100 public 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]/div[2]/span/label/span[1][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("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $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 year.';
125 $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text);
131 public function _configureMembershipPage() {
132 static $pageId = NULL;
135 $this->webtestLogin();
137 //add payment processor.
138 $hash = substr(sha1(rand()), 0, 7);
139 $rand = 2 * rand(2, 50);
140 $processorName = "Webtest Auto Renew AuthNet" . $hash;
141 $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
143 // -- start updating membership types
144 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom");
146 $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')]");
148 $this->type("duration_interval", "1");
149 $this->select("duration_unit", "label=year");
151 $this->click("_qf_MembershipType_upload-bottom");
152 $this->waitForPageToLoad($this->getTimeoutMsec());
154 $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom");
156 $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')]");
158 $this->type("duration_interval", "1");
159 $this->select("duration_unit", "label=year");
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(
171 array('id' => 1, 'auto_renew' => 1),
172 array('id' => 2, 'auto_renew' => 1),
174 $memPriceSetId = NULL;
176 $profilePreId = NULL;
177 $profilePostId = NULL;
182 $contributionTitle = "Title $hash";
183 $pageId = $this->webtestAddContributionPage($hash,
186 array($processorName => 'AuthNet'),
203 //make sure we do have required permissions.
204 $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
205 $this->changePermissions($permissions);
207 // now logout and do membership test that way
208 $this->webtestLogout();