Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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).'; | |
77a2a633 | 54 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $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).'; | |
77a2a633 | 60 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $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).'; | |
77a2a633 | 87 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $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).'; | |
77a2a633 | 93 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $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).'; | |
77a2a633 | 115 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $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).'; | |
77a2a633 | 121 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); |
6a488035 TO |
122 | } |
123 | ||
4cbe18b8 EM |
124 | /** |
125 | * @return null | |
126 | */ | |
6a488035 TO |
127 | function _configureMembershipPage() { |
128 | static $pageId = NULL; | |
129 | ||
130 | if (!$pageId) { | |
42daf119 | 131 | $this->webtestLogin(); |
6a488035 TO |
132 | |
133 | //add payment processor. | |
42daf119 CW |
134 | $hash = substr(sha1(rand()), 0, 7); |
135 | $rand = 2 * rand(2, 50); | |
6a488035 TO |
136 | $processorName = "Webtest Auto Renew AuthNet" . $hash; |
137 | $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); | |
138 | ||
139 | // -- start updating membership types | |
f2ff7d84 | 140 | $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom"); |
6a488035 | 141 | |
6a488035 TO |
142 | $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')]"); |
143 | ||
144 | $this->type("duration_interval", "1"); | |
145 | $this->select("duration_unit", "label=year"); | |
76e86fd8 | 146 | |
6a488035 TO |
147 | |
148 | $this->click("_qf_MembershipType_upload-bottom"); | |
149 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
150 | ||
f2ff7d84 | 151 | $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom"); |
6a488035 | 152 | |
6a488035 TO |
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')]"); |
154 | ||
155 | $this->type("duration_interval", "1"); | |
156 | $this->select("duration_unit", "label=year"); | |
157 | ||
6a488035 TO |
158 | |
159 | $this->click("_qf_MembershipType_upload-bottom"); | |
160 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
161 | ||
6a488035 | 162 | // create contribution page with randomized title and default params |
42daf119 CW |
163 | $amountSection = FALSE; |
164 | $payLater = TRUE; | |
165 | $onBehalf = FALSE; | |
166 | $pledges = FALSE; | |
167 | $recurring = TRUE; | |
6a488035 TO |
168 | $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), |
169 | array('id' => 2, 'auto_renew' => 1), | |
170 | ); | |
171 | $memPriceSetId = NULL; | |
42daf119 CW |
172 | $friend = TRUE; |
173 | $profilePreId = NULL; | |
6a488035 | 174 | $profilePostId = NULL; |
42daf119 CW |
175 | $premiums = TRUE; |
176 | $widget = TRUE; | |
177 | $pcp = TRUE; | |
6a488035 TO |
178 | |
179 | $contributionTitle = "Title $hash"; | |
180 | $pageId = $this->webtestAddContributionPage($hash, | |
181 | $rand, | |
182 | $contributionTitle, | |
183 | array($processorName => 'AuthNet'), | |
184 | $amountSection, | |
185 | $payLater, | |
186 | $onBehalf, | |
187 | $pledges, | |
188 | $recurring, | |
189 | $membershipTypes, | |
190 | $memPriceSetId, | |
191 | $friend, | |
192 | $profilePreId, | |
193 | $profilePostId, | |
194 | $premiums, | |
195 | $widget, | |
196 | $pcp, | |
197 | FALSE | |
198 | ); | |
199 | ||
200 | //make sure we do have required permissions. | |
77a2a633 | 201 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); |
6a488035 TO |
202 | $this->changePermissions($permissions); |
203 | ||
204 | // now logout and do membership test that way | |
42daf119 | 205 | $this->webtestLogout(); |
6a488035 TO |
206 | } |
207 | ||
208 | return $pageId; | |
209 | } | |
210 | } | |
211 |