Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_OnlineAutoRenewMembershipTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testOnlineAutoRenewMembershipAnonymous() { | |
39 | //configure membership signup page. | |
40 | $pageId = $this->_configureMembershipPage(); | |
41 | ||
42 | //now do the test membership signup. | |
f2ff7d84 | 43 | $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); |
76e86fd8 | 44 | |
63d14d48 | 45 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]"); |
6a488035 TO |
46 | |
47 | $this->click("auto_renew"); | |
48 | ||
49 | $this->webtestAddCreditCardDetails(); | |
50 | ||
51 | list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails(); | |
52 | ||
53 | $this->type('email-5', "{$lastName}@example.com"); | |
54 | ||
225a8648 | 55 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
56 | |
57 | $text = 'I want this membership to be renewed automatically every 1 year(s).'; | |
63d14d48 | 58 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $text, 'Missing text: ' . $text); |
6a488035 TO |
59 | |
60 | $this->click("_qf_Confirm_next-bottom"); | |
61 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
62 | ||
63 | $text = 'This membership will be renewed automatically every 1 year(s).'; | |
63d14d48 | 64 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text); |
6a488035 TO |
65 | } |
66 | ||
67 | function testOnlineAutoRenewMembershipAuthenticated() { | |
68 | //configure membership signup page. | |
69 | $pageId = $this->_configureMembershipPage(); | |
70 | ||
6a488035 TO |
71 | $this->webtestLogin(); |
72 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
73 | ||
74 | //now do the test membership signup. | |
f2ff7d84 | 75 | $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); |
76e86fd8 | 76 | |
63d14d48 | 77 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]"); |
6a488035 TO |
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).'; | |
63d14d48 | 91 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $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).'; | |
63d14d48 | 97 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $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 | 105 | $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); |
76e86fd8 | 106 | |
63d14d48 | 107 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]"); |
6a488035 TO |
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).'; | |
63d14d48 | 119 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $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).'; | |
63d14d48 | 125 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text); |
6a488035 TO |
126 | } |
127 | ||
4cbe18b8 EM |
128 | /** |
129 | * @return null | |
130 | */ | |
6a488035 TO |
131 | function _configureMembershipPage() { |
132 | static $pageId = NULL; | |
133 | ||
134 | if (!$pageId) { | |
42daf119 | 135 | $this->webtestLogin(); |
6a488035 TO |
136 | |
137 | //add payment processor. | |
42daf119 CW |
138 | $hash = substr(sha1(rand()), 0, 7); |
139 | $rand = 2 * rand(2, 50); | |
6a488035 TO |
140 | $processorName = "Webtest Auto Renew AuthNet" . $hash; |
141 | $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); | |
142 | ||
143 | // -- start updating membership types | |
f2ff7d84 | 144 | $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom"); |
6a488035 | 145 | |
6a488035 TO |
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')]"); |
147 | ||
148 | $this->type("duration_interval", "1"); | |
149 | $this->select("duration_unit", "label=year"); | |
76e86fd8 | 150 | |
6a488035 TO |
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 | ||
6a488035 TO |
162 | |
163 | $this->click("_qf_MembershipType_upload-bottom"); | |
164 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
165 | ||
6a488035 | 166 | // create contribution page with randomized title and default params |
42daf119 CW |
167 | $amountSection = FALSE; |
168 | $payLater = TRUE; | |
169 | $onBehalf = FALSE; | |
170 | $pledges = FALSE; | |
171 | $recurring = TRUE; | |
6a488035 TO |
172 | $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), |
173 | array('id' => 2, 'auto_renew' => 1), | |
174 | ); | |
175 | $memPriceSetId = NULL; | |
42daf119 CW |
176 | $friend = TRUE; |
177 | $profilePreId = NULL; | |
6a488035 | 178 | $profilePostId = NULL; |
42daf119 CW |
179 | $premiums = TRUE; |
180 | $widget = TRUE; | |
181 | $pcp = TRUE; | |
6a488035 TO |
182 | |
183 | $contributionTitle = "Title $hash"; | |
184 | $pageId = $this->webtestAddContributionPage($hash, | |
185 | $rand, | |
186 | $contributionTitle, | |
187 | array($processorName => 'AuthNet'), | |
188 | $amountSection, | |
189 | $payLater, | |
190 | $onBehalf, | |
191 | $pledges, | |
192 | $recurring, | |
193 | $membershipTypes, | |
194 | $memPriceSetId, | |
195 | $friend, | |
196 | $profilePreId, | |
197 | $profilePostId, | |
198 | $premiums, | |
199 | $widget, | |
200 | $pcp, | |
201 | FALSE | |
202 | ); | |
203 | ||
204 | //make sure we do have required permissions. | |
77a2a633 | 205 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); |
6a488035 TO |
206 | $this->changePermissions($permissions); |
207 | ||
208 | // now logout and do membership test that way | |
42daf119 | 209 | $this->webtestLogout(); |
6a488035 TO |
210 | } |
211 | ||
212 | return $pageId; | |
213 | } | |
214 | } | |
215 |