Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 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 | ||
00be9182 | 38 | public function testOnlineAutoRenewMembershipAnonymous() { |
6a488035 TO |
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 | ||
62815961 | 63 | $text = 'This membership will be renewed automatically every year.'; |
63d14d48 | 64 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text); |
6a488035 TO |
65 | } |
66 | ||
00be9182 | 67 | public function testOnlineAutoRenewMembershipAuthenticated() { |
6a488035 TO |
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 | ||
62815961 | 96 | $text = 'This membership will be renewed automatically every year.'; |
63d14d48 | 97 | $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text); |
6a488035 TO |
98 | } |
99 | ||
00be9182 | 100 | public function testOnlinePendingAutoRenewMembershipAnonymous() { |
6a488035 TO |
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 | ||
62815961 | 124 | $text = 'This membership will be renewed automatically every year.'; |
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 | */ | |
00be9182 | 131 | public function _configureMembershipPage() { |
6a488035 TO |
132 | static $pageId = NULL; |
133 | ||
134 | if (!$pageId) { | |
6c6e6187 | 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 | $this->click("_qf_MembershipType_upload-bottom"); |
152 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
153 | ||
f2ff7d84 | 154 | $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom"); |
6a488035 | 155 | |
6a488035 TO |
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')]"); |
157 | ||
158 | $this->type("duration_interval", "1"); | |
159 | $this->select("duration_unit", "label=year"); | |
160 | ||
6a488035 TO |
161 | $this->click("_qf_MembershipType_upload-bottom"); |
162 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
163 | ||
6a488035 | 164 | // create contribution page with randomized title and default params |
42daf119 CW |
165 | $amountSection = FALSE; |
166 | $payLater = TRUE; | |
167 | $onBehalf = FALSE; | |
168 | $pledges = FALSE; | |
169 | $recurring = TRUE; | |
92915c55 TO |
170 | $membershipTypes = array( |
171 | array('id' => 1, 'auto_renew' => 1), | |
6a488035 TO |
172 | array('id' => 2, 'auto_renew' => 1), |
173 | ); | |
174 | $memPriceSetId = NULL; | |
42daf119 CW |
175 | $friend = TRUE; |
176 | $profilePreId = NULL; | |
6a488035 | 177 | $profilePostId = NULL; |
42daf119 CW |
178 | $premiums = TRUE; |
179 | $widget = TRUE; | |
180 | $pcp = TRUE; | |
6a488035 TO |
181 | |
182 | $contributionTitle = "Title $hash"; | |
183 | $pageId = $this->webtestAddContributionPage($hash, | |
184 | $rand, | |
185 | $contributionTitle, | |
186 | array($processorName => 'AuthNet'), | |
187 | $amountSection, | |
188 | $payLater, | |
189 | $onBehalf, | |
190 | $pledges, | |
191 | $recurring, | |
192 | $membershipTypes, | |
193 | $memPriceSetId, | |
194 | $friend, | |
195 | $profilePreId, | |
196 | $profilePostId, | |
197 | $premiums, | |
198 | $widget, | |
199 | $pcp, | |
200 | FALSE | |
201 | ); | |
202 | ||
203 | //make sure we do have required permissions. | |
6c6e6187 | 204 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); |
6a488035 TO |
205 | $this->changePermissions($permissions); |
206 | ||
207 | // now logout and do membership test that way | |
42daf119 | 208 | $this->webtestLogout(); |
6a488035 TO |
209 | } |
210 | ||
211 | return $pageId; | |
212 | } | |
96025800 | 213 | |
6a488035 | 214 | } |