Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testOnlineAutoRenewMembershipAnonymous() { | |
36 | //configure membership signup page. | |
37 | $pageId = $this->_configureMembershipPage(); | |
38 | ||
39 | //now do the test membership signup. | |
f2ff7d84 PJ |
40 | $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); |
41 | ||
6a488035 TO |
42 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
43 | ||
44 | $this->click("auto_renew"); | |
45 | ||
46 | $this->webtestAddCreditCardDetails(); | |
47 | ||
48 | list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails(); | |
49 | ||
50 | $this->type('email-5', "{$lastName}@example.com"); | |
51 | ||
52 | $this->click("_qf_Main_upload-bottom"); | |
53 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
54 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
55 | ||
56 | $text = 'I want this membership to be renewed automatically every 1 year(s).'; | |
f2ff7d84 | 57 | $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); |
6a488035 TO |
58 | |
59 | $this->click("_qf_Confirm_next-bottom"); | |
60 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
61 | ||
62 | $text = 'This membership will be renewed automatically every 1 year(s).'; | |
f2ff7d84 | 63 | $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); |
6a488035 TO |
64 | } |
65 | ||
66 | function testOnlineAutoRenewMembershipAuthenticated() { | |
67 | //configure membership signup page. | |
68 | $pageId = $this->_configureMembershipPage(); | |
69 | ||
70 | $this->open($this->sboxPath); | |
71 | $this->webtestLogin(); | |
72 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
73 | ||
74 | //now do the test membership signup. | |
f2ff7d84 PJ |
75 | $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); |
76 | ||
6a488035 TO |
77 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
78 | ||
79 | $this->click("auto_renew"); | |
80 | ||
81 | $this->webtestAddCreditCardDetails(); | |
82 | ||
83 | list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails(); | |
84 | ||
85 | $this->type('email-5', "{$lastName}@example.com"); | |
86 | ||
87 | $this->click("_qf_Main_upload-bottom"); | |
6a488035 TO |
88 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); |
89 | ||
90 | $text = 'I want this membership to be renewed automatically every 1 year(s).'; | |
f2ff7d84 | 91 | $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); |
6a488035 TO |
92 | |
93 | $this->click("_qf_Confirm_next-bottom"); | |
94 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
95 | ||
96 | $text = 'This membership will be renewed automatically every 1 year(s).'; | |
f2ff7d84 | 97 | $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); |
6a488035 TO |
98 | } |
99 | ||
100 | function testOnlinePendingAutoRenewMembershipAnonymous() { | |
101 | //configure membership signup page. | |
102 | $pageId = $this->_configureMembershipPage(); | |
103 | ||
104 | //now do the test membership signup. | |
f2ff7d84 PJ |
105 | $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); |
106 | ||
6a488035 TO |
107 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
108 | ||
109 | $this->click("auto_renew"); | |
110 | ||
111 | $this->webtestAddCreditCardDetails(); | |
112 | list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails(); | |
113 | $this->type('email-5', "{$lastName}@example.com"); | |
114 | ||
115 | $this->click("_qf_Main_upload-bottom"); | |
6a488035 TO |
116 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); |
117 | ||
118 | $text = 'I want this membership to be renewed automatically every 1 year(s).'; | |
f2ff7d84 | 119 | $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); |
6a488035 TO |
120 | |
121 | $this->click("_qf_Confirm_next-bottom"); | |
122 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
123 | ||
124 | $text = 'This membership will be renewed automatically every 1 year(s).'; | |
f2ff7d84 | 125 | $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); |
6a488035 TO |
126 | } |
127 | ||
128 | function _configureMembershipPage() { | |
129 | static $pageId = NULL; | |
130 | ||
131 | if (!$pageId) { | |
132 | $this->open($this->sboxPath); | |
133 | $this->webtestLogin(); | |
134 | ||
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'); | |
140 | ||
141 | // -- start updating membership types | |
f2ff7d84 | 142 | $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom"); |
6a488035 | 143 | |
6a488035 TO |
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')]"); |
145 | ||
146 | $this->type("duration_interval", "1"); | |
147 | $this->select("duration_unit", "label=year"); | |
148 | ||
149 | //wait for the auto-complete member_of_contact to populate | |
150 | sleep(2); | |
151 | ||
152 | $this->click("_qf_MembershipType_upload-bottom"); | |
153 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
154 | ||
f2ff7d84 | 155 | $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom"); |
6a488035 | 156 | |
6a488035 TO |
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')]"); |
158 | ||
159 | $this->type("duration_interval", "1"); | |
160 | $this->select("duration_unit", "label=year"); | |
161 | ||
162 | //wait for the auto-complete member_of_contact to populate | |
163 | sleep(2); | |
164 | ||
165 | $this->click("_qf_MembershipType_upload-bottom"); | |
166 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
167 | ||
168 | ||
169 | // create contribution page with randomized title and default params | |
170 | $amountSection = FALSE; | |
171 | $payLater = TRUE; | |
172 | $onBehalf = FALSE; | |
173 | $pledges = FALSE; | |
174 | $recurring = TRUE; | |
175 | $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), | |
176 | array('id' => 2, 'auto_renew' => 1), | |
177 | ); | |
178 | $memPriceSetId = NULL; | |
179 | $friend = TRUE; | |
180 | $profilePreId = NULL; | |
181 | $profilePostId = NULL; | |
182 | $premiums = TRUE; | |
183 | $widget = TRUE; | |
184 | $pcp = TRUE; | |
185 | ||
186 | $contributionTitle = "Title $hash"; | |
187 | $pageId = $this->webtestAddContributionPage($hash, | |
188 | $rand, | |
189 | $contributionTitle, | |
190 | array($processorName => 'AuthNet'), | |
191 | $amountSection, | |
192 | $payLater, | |
193 | $onBehalf, | |
194 | $pledges, | |
195 | $recurring, | |
196 | $membershipTypes, | |
197 | $memPriceSetId, | |
198 | $friend, | |
199 | $profilePreId, | |
200 | $profilePostId, | |
201 | $premiums, | |
202 | $widget, | |
203 | $pcp, | |
204 | FALSE | |
205 | ); | |
206 | ||
207 | //make sure we do have required permissions. | |
208 | $permissions = array("edit-1-make-online-contributions"); | |
209 | $this->changePermissions($permissions); | |
210 | ||
211 | // now logout and do membership test that way | |
f2ff7d84 | 212 | $this->openCiviPage('logout', 'reset=1', NULL); |
6a488035 TO |
213 | } |
214 | ||
215 | return $pageId; | |
216 | } | |
217 | } | |
218 |