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