Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_OnlineMembershipRenewTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
b45c587e CW |
38 | /** |
39 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
40 | */ | |
00be9182 | 41 | public function testOnlineMembershipRenew() { |
6a488035 TO |
42 | // a random 7-char string and an even number to make this pass unique |
43 | $hash = substr(sha1(rand()), 0, 7); | |
44 | $rand = 2 * rand(2, 50); | |
45 | ||
6a488035 TO |
46 | // Log in using webtestLogin() method |
47 | $this->webtestLogin(); | |
48 | ||
c3ad8633 CW |
49 | // Use default payment processor |
50 | $processorName = 'Test Processor'; | |
6a488035 TO |
51 | $this->webtestAddPaymentProcessor($processorName); |
52 | ||
42daf119 | 53 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next"); |
6a488035 TO |
54 | // this contribution page for membership signup |
55 | // select newly created processor | |
56 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
2ac4a694 | 57 | $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName); |
6a488035 TO |
58 | $this->check($xpath); |
59 | ||
60 | // save | |
61 | $this->waitForElementPresent("_qf_Amount_next"); | |
b45c587e | 62 | $this->clickLink('_qf_Amount_next'); |
6a488035 TO |
63 | |
64 | // go to Membership block | |
65 | $this->click('css=#tab_membership a'); | |
66 | $this->waitForElementPresent("member_is_active"); | |
67 | $this->check("member_is_active"); | |
76e86fd8 CW |
68 | |
69 | $this->waitForElementPresent("new_title"); | |
70 | ||
6a488035 | 71 | if ($this->isElementPresent("member_price_set_id")) { |
6c6e6187 | 72 | $this->waitForElementPresent("member_price_set_id"); |
76e86fd8 | 73 | |
6c6e6187 | 74 | $this->select("member_price_set_id", "label=- none -"); |
6a488035 | 75 | } |
76e86fd8 | 76 | |
6a488035 TO |
77 | $this->waitForElementPresent("membership_type-block"); |
78 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
79 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
80 | $this->click("_qf_MembershipBlock_next-bottom"); | |
81 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
76e86fd8 | 82 | |
6a488035 TO |
83 | // go to Profiles |
84 | $this->click('css=#tab_custom a'); | |
85 | ||
86 | // fill in Profiles | |
87 | $this->waitForElementPresent('custom_pre_id'); | |
73072f84 | 88 | $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1'); |
6a488035 TO |
89 | |
90 | // save | |
91 | $this->click('_qf_Custom_upload_done'); | |
92 | $this->waitForPageToLoad(); | |
93 | ||
94 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
42daf119 CW |
95 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
96 | $email = $firstName . "@example.com"; | |
6a488035 TO |
97 | |
98 | //logout | |
42daf119 | 99 | $this->webtestLogout(); |
6a488035 TO |
100 | |
101 | //Go to online membership signup page | |
42daf119 | 102 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
76e86fd8 | 103 | |
b21dd815 | 104 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]"); |
6a488035 TO |
105 | |
106 | //Type first name and last name and email | |
107 | $this->type("first_name", $firstName); | |
108 | $this->type("last_name", $lastName); | |
109 | $this->type("email-5", $email); | |
73072f84 | 110 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
111 | |
112 | //Credit Card Info | |
113 | $this->select("credit_card_type", "value=Visa"); | |
114 | $this->select("credit_card_type", "label=Visa"); | |
115 | $this->type("credit_card_number", "4111111111111111"); | |
116 | $this->type("cvv2", "000"); | |
117 | $this->select("credit_card_exp_date[M]", "value=1"); | |
118 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
119 | ||
120 | //Billing Info | |
121 | $this->type("billing_first_name", $firstName . "billing"); | |
122 | $this->type("billing_last_name", $lastName . "billing"); | |
123 | $this->type("billing_street_address-5", "15 Main St."); | |
124 | $this->type(" billing_city-5", "San Jose"); | |
125 | $this->select("billing_country_id-5", "value=1228"); | |
126 | $this->select("billing_state_province_id-5", "value=1004"); | |
127 | $this->type("billing_postal_code-5", "94129"); | |
128 | ||
225a8648 | 129 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
130 | |
131 | $this->click("_qf_Confirm_next-bottom"); | |
6a488035 TO |
132 | |
133 | // Log in using webtestLogin() method | |
6a488035 TO |
134 | $this->webtestLogin(); |
135 | //Find Member | |
42daf119 | 136 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 | 137 | |
8fb46c61 | 138 | $this->type("sort_name", "$lastName $firstName"); |
a1c7d42f CW |
139 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
140 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
141 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
142 | ||
143 | //View Membership Record | |
144 | $verifyMembershipData = array( | |
145 | 'Member' => $firstName . ' ' . $lastName, | |
146 | 'Membership Type' => 'Student', | |
147 | 'Status' => 'New', | |
148 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
149 | ); | |
150 | foreach ($verifyMembershipData as $label => $value) { | |
151 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
152 | preg_quote($value) | |
153 | ); | |
154 | } | |
155 | ||
156 | //logout | |
42daf119 | 157 | $this->webtestLogout(); |
6a488035 | 158 | |
42daf119 | 159 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 | 160 | |
b21dd815 | 161 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]"); |
6a488035 TO |
162 | |
163 | //Type first name and last name and email | |
164 | $this->type("first_name", $firstName); | |
165 | $this->type("last_name", $lastName); | |
166 | $this->type("email-5", $email); | |
73072f84 | 167 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
168 | |
169 | //Credit Card Info | |
170 | $this->select("credit_card_type", "value=Visa"); | |
171 | $this->select("credit_card_type", "label=Visa"); | |
172 | $this->type("credit_card_number", "4111111111111111"); | |
173 | $this->type("cvv2", "000"); | |
174 | $this->select("credit_card_exp_date[M]", "value=1"); | |
175 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
176 | ||
177 | //Billing Info | |
178 | $this->type("billing_first_name", $firstName . "billing"); | |
179 | $this->type("billing_last_name", $lastName . "billing"); | |
180 | $this->type("billing_street_address-5", "15 Main St."); | |
181 | $this->type(" billing_city-5", "San Jose"); | |
182 | $this->select("billing_country_id-5", "value=1228"); | |
183 | $this->select("billing_state_province_id-5", "value=1004"); | |
184 | $this->type("billing_postal_code-5", "94129"); | |
185 | ||
225a8648 | 186 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 | 187 | $this->click("_qf_Confirm_next-bottom"); |
6a488035 | 188 | |
6a488035 TO |
189 | $this->webtestLogin(); |
190 | //Find Member | |
42daf119 | 191 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 | 192 | |
8fb46c61 | 193 | $this->type("sort_name", "$lastName $firstName"); |
a1c7d42f CW |
194 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
195 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
196 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
197 | ||
198 | //View Membership Record | |
199 | $verifyMembershipData = array( | |
200 | 'Member' => $firstName . ' ' . $lastName, | |
201 | 'Membership Type' => 'Student', | |
202 | 'Status' => 'New', | |
203 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
204 | ); | |
205 | foreach ($verifyMembershipData as $label => $value) { | |
206 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
207 | preg_quote($value) | |
208 | ); | |
209 | } | |
210 | } | |
211 | ||
b45c587e CW |
212 | /** |
213 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
214 | */ | |
00be9182 | 215 | public function testOnlineMembershipRenewChangeType() { |
6a488035 TO |
216 | // a random 7-char string and an even number to make this pass unique |
217 | $hash = substr(sha1(rand()), 0, 7); | |
218 | $rand = 2 * rand(2, 50); | |
219 | ||
6a488035 TO |
220 | // Log in using webtestLogin() method |
221 | $this->webtestLogin(); | |
222 | ||
c3ad8633 CW |
223 | // Use default payment processor |
224 | $processorName = 'Test Processor'; | |
6a488035 TO |
225 | $this->webtestAddPaymentProcessor($processorName); |
226 | ||
42daf119 | 227 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next'); |
6a488035 TO |
228 | |
229 | //this contribution page for membership signup | |
230 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
2ac4a694 | 231 | $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName); |
6a488035 TO |
232 | $this->check($xpath); |
233 | ||
234 | // save | |
235 | $this->waitForElementPresent('_qf_Amount_next'); | |
236 | $this->click('_qf_Amount_next'); | |
237 | $this->waitForPageToLoad(); | |
238 | ||
239 | // go to Membership block | |
240 | $this->click('css=#tab_membership a'); | |
241 | $this->waitForElementPresent("member_is_active"); | |
242 | $this->check("member_is_active"); | |
76e86fd8 | 243 | |
6a488035 TO |
244 | $this->waitForElementPresent("new_title"); |
245 | if ($this->isElementPresent("member_price_set_id")) { | |
6c6e6187 | 246 | $this->waitForElementPresent("member_price_set_id"); |
76e86fd8 | 247 | |
6c6e6187 | 248 | $this->select("member_price_set_id", "label=- none -"); |
6a488035 | 249 | } |
76e86fd8 | 250 | |
6a488035 TO |
251 | $this->waitForElementPresent("membership_type-block"); |
252 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
253 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
254 | $this->click("_qf_MembershipBlock_next-bottom"); | |
255 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
76e86fd8 | 256 | |
6a488035 TO |
257 | // go to Profiles |
258 | $this->click('css=#tab_custom a'); | |
259 | ||
260 | // fill in Profiles | |
261 | $this->waitForElementPresent('custom_pre_id'); | |
73072f84 | 262 | $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1'); |
6a488035 TO |
263 | |
264 | // save | |
265 | $this->click('_qf_Custom_upload_done'); | |
266 | $this->waitForPageToLoad(); | |
267 | ||
268 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
269 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
270 | ||
271 | //Go to online membership signup page | |
42daf119 | 272 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
b21dd815 | 273 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[1]/span/label/span[1][contains(text(),'General')]"); |
6a488035 TO |
274 | //Type first name and last name |
275 | $this->type("first_name", $firstName); | |
276 | $this->type("last_name", $lastName); | |
277 | ||
73072f84 | 278 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
279 | //Credit Card Info |
280 | $this->select("credit_card_type", "value=Visa"); | |
281 | $this->select("credit_card_type", "label=Visa"); | |
282 | $this->type("credit_card_number", "4111111111111111"); | |
283 | $this->type("cvv2", "000"); | |
284 | $this->select("credit_card_exp_date[M]", "value=1"); | |
285 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
286 | ||
287 | //Billing Info | |
288 | $this->type("billing_first_name", $firstName . "billing"); | |
289 | $this->type("billing_last_name", $lastName . "billing"); | |
290 | $this->type("billing_street_address-5", "15 Main St."); | |
291 | $this->type(" billing_city-5", "San Jose"); | |
292 | $this->select("billing_country_id-5", "value=1228"); | |
293 | $this->select("billing_state_province_id-5", "value=1004"); | |
294 | $this->type("billing_postal_code-5", "94129"); | |
295 | ||
225a8648 | 296 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
297 | |
298 | $this->click("_qf_Confirm_next-bottom"); | |
6a488035 TO |
299 | |
300 | //Find Member | |
42daf119 | 301 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 | 302 | |
8fb46c61 | 303 | $this->type("sort_name", "$lastName $firstName"); |
a1c7d42f CW |
304 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
305 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
306 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
307 | ||
a471a3b6 | 308 | $membershipCreatedId = $this->urlArg('id'); |
6a488035 TO |
309 | |
310 | $memberSince = date('F jS, Y'); | |
311 | ||
312 | //View Membership Record | |
313 | $verifyMembershipData = array( | |
314 | 'Member' => $firstName . ' ' . $lastName, | |
315 | 'Membership Type' => 'General', | |
316 | 'Status' => 'New', | |
317 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
318 | ); | |
319 | foreach ($verifyMembershipData as $label => $value) { | |
320 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
321 | preg_quote($value) | |
322 | ); | |
323 | } | |
42daf119 | 324 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
b21dd815 | 325 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]"); |
6a488035 TO |
326 | |
327 | //Credit Card Info | |
328 | $this->select("credit_card_type", "value=Visa"); | |
329 | $this->select("credit_card_type", "label=Visa"); | |
330 | $this->type("credit_card_number", "4111111111111111"); | |
331 | $this->type("cvv2", "000"); | |
332 | $this->select("credit_card_exp_date[M]", "value=1"); | |
333 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
225a8648 | 334 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 | 335 | $this->click("_qf_Confirm_next-bottom"); |
6a488035 TO |
336 | |
337 | //Find Member | |
42daf119 | 338 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 | 339 | |
8fb46c61 | 340 | $this->type("sort_name", "$lastName $firstName"); |
a1c7d42f CW |
341 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
342 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
343 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
344 | ||
a471a3b6 | 345 | $membershipRenewedId = $this->urlArg('id'); |
6a488035 TO |
346 | |
347 | //View Membership Record | |
348 | $verifyMembershipData = array( | |
349 | 'Member' => $firstName . ' ' . $lastName, | |
350 | 'Membership Type' => 'Student', | |
351 | 'Status' => 'New', | |
352 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
353 | 'Member Since' => $memberSince, | |
354 | ); | |
355 | foreach ($verifyMembershipData as $label => $value) { | |
356 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
357 | preg_quote($value) | |
358 | ); | |
359 | } | |
360 | $this->assertEquals($membershipCreatedId, $membershipRenewedId); | |
361 | } | |
362 | ||
00be9182 | 363 | public function testUpdateInheritedMembershipOnBehalfOfRenewal() { |
42daf119 CW |
364 | // Log in as admin |
365 | $this->webtestLogin('admin'); | |
76e86fd8 | 366 | |
42daf119 | 367 | $this->enableComponents('CiviMember'); |
6a488035 | 368 | |
42daf119 CW |
369 | //check for online contribution and profile listings permissions |
370 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); | |
371 | $this->changePermissions($permissions); | |
372 | ||
373 | // Log in as normal user | |
6a488035 TO |
374 | $this->webtestLogin(); |
375 | ||
42daf119 | 376 | $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); |
6a488035 TO |
377 | |
378 | $title = substr(sha1(rand()), 0, 7); | |
379 | $this->type('organization_name', "Organization $title"); | |
380 | $this->type('email_1_email', "$title@org.com"); | |
381 | $this->click('_qf_Contact_upload_view'); | |
382 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
383 | ||
2ac4a694 | 384 | $this->waitForText('crm-notification-container', "Organization $title has been created."); |
6a488035 | 385 | |
071a6d2e | 386 | $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse"); |
6a488035 TO |
387 | |
388 | $this->click('link=Add Membership Type'); | |
389 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
390 | ||
391 | $membershipTypeTitle = "Membership Type $title"; | |
392 | $this->type('name', "Membership Type $title"); | |
76e86fd8 | 393 | |
73072f84 | 394 | $this->select2('member_of_contact_id', $title); |
6a488035 TO |
395 | |
396 | $this->type('minimum_fee', '100'); | |
481a74f4 | 397 | $this->select('financial_type_id', 'value=2'); |
6a488035 TO |
398 | $this->type('duration_interval', 1); |
399 | $this->select('duration_unit', 'label=year'); | |
73072f84 | 400 | $this->select('period_type', 'value=rolling'); |
6a488035 TO |
401 | |
402 | $this->removeSelection('relationship_type_id', 'label=- select -'); | |
403 | $this->addSelection('relationship_type_id', 'label=Employer of'); | |
404 | ||
405 | $this->click('_qf_MembershipType_upload-bottom'); | |
406 | $this->waitForElementPresent('link=Add Membership Type'); | |
2ac4a694 | 407 | $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved."); |
6a488035 | 408 | |
5c80555f WA |
409 | $this->waitForElementPresent("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href"); |
410 | $url = $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href"); | |
6a488035 TO |
411 | $matches = array(); |
412 | preg_match('/id=([0-9]+)/', $url, $matches); | |
413 | $membershipTypeId = $matches[1]; | |
414 | ||
c3ad8633 CW |
415 | // Use default payment processor |
416 | $processorName = 'Test Processor'; | |
6a488035 | 417 | |
6a488035 | 418 | // create contribution page with randomized title and default params |
42daf119 CW |
419 | $hash = substr(sha1(rand()), 0, 7); |
420 | $rand = 2 * rand(2, 50); | |
6a488035 | 421 | $amountSection = FALSE; |
42daf119 CW |
422 | $payLater = FALSE; |
423 | $onBehalf = FALSE; | |
424 | $pledges = FALSE; | |
425 | $recurring = FALSE; | |
426 | $memberships = FALSE; | |
6a488035 | 427 | $memPriceSetId = NULL; |
42daf119 CW |
428 | $friend = FALSE; |
429 | $profilePreId = 1; | |
6a488035 | 430 | $profilePostId = NULL; |
42daf119 CW |
431 | $premiums = FALSE; |
432 | $widget = FALSE; | |
433 | $pcp = FALSE; | |
6a488035 TO |
434 | |
435 | $contributionTitle = "Title $hash"; | |
436 | $pageId = $this->webtestAddContributionPage($hash, | |
437 | $rand, | |
438 | $contributionTitle, | |
439 | array($processorName => 'Dummy'), | |
440 | $amountSection, | |
441 | $payLater, | |
442 | $onBehalf, | |
443 | $pledges, | |
444 | $recurring, | |
445 | $memberships, | |
446 | $memPriceSetId, | |
447 | $friend, | |
448 | $profilePreId, | |
449 | $profilePostId, | |
450 | $premiums, | |
451 | $widget, | |
452 | $pcp, | |
453 | TRUE | |
454 | ); | |
455 | ||
456 | $hash = substr(sha1(rand()), 0, 7); | |
071a6d2e | 457 | $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id=$pageId"); |
6a488035 TO |
458 | |
459 | $this->click('link=Title'); | |
460 | $this->waitForElementPresent('_qf_Settings_cancel-bottom'); | |
461 | $this->click('is_organization'); | |
c900afb1 | 462 | $this->select("xpath=//input[@id='onbehalf_profile_id']/parent::td/div/div/span/select", "value=9"); |
6a488035 TO |
463 | $this->type('for_organization', "On behalf $hash"); |
464 | $this->click('_qf_Settings_next-bottom'); | |
465 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
466 | ||
467 | $this->click('link=Memberships'); | |
468 | $this->waitForElementPresent('_qf_MembershipBlock_cancel-bottom'); | |
469 | $this->click('member_is_active'); | |
470 | $this->type('new_title', "Title - New Membership $hash"); | |
471 | $this->type('renewal_title', "Title - Renewals $hash"); | |
472 | $this->click("membership_type_{$membershipTypeId}"); | |
473 | $this->click('is_required'); | |
474 | $this->click('_qf_MembershipBlock_next-bottom'); | |
475 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
476 | ||
477 | //logout | |
42daf119 | 478 | $this->webtestLogout(); |
6a488035 TO |
479 | |
480 | //get Url for Live Contribution Page | |
071a6d2e | 481 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom'); |
b21dd815 | 482 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]"); |
42daf119 CW |
483 | $firstName = 'Eia' . substr(sha1(rand()), 0, 4); |
484 | $lastName = 'Ande' . substr(sha1(rand()), 0, 4); | |
485 | $name = $firstName . ' ' . $lastName; | |
6a488035 TO |
486 | $organisationName = 'TestOrg' . substr(sha1(rand()), 0, 7); |
487 | ||
488 | $email = $firstName . '@example.com'; | |
489 | $this->type('email-5', $email); | |
490 | $this->click('is_for_organization'); | |
491 | $this->type('onbehalf_organization_name', $organisationName); | |
492 | $this->type('onbehalf_phone-3-1', '2222-222222'); | |
493 | $this->type('onbehalf_email-3', $organisationName . '@example.com'); | |
494 | $this->type('onbehalf_street_address-3', '54A Excelsior Ave. Apt 1C'); | |
495 | $this->type('onbehalf_city-3', 'Driftwood'); | |
496 | $this->type('onbehalf_postal_code-3', '75653'); | |
497 | $this->select('onbehalf_country-3', "value=1228"); | |
498 | $this->select('onbehalf_state_province-3', "value=1061"); | |
499 | ||
500 | $this->type('first_name', $firstName); | |
501 | $this->type('last_name', $lastName); | |
73072f84 | 502 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
503 | |
504 | //Credit Card Info | |
505 | $this->select("credit_card_type", "value=Visa"); | |
506 | $this->select("credit_card_type", "label=Visa"); | |
507 | $this->type("credit_card_number", "4111111111111111"); | |
508 | $this->type("cvv2", "000"); | |
509 | $this->select("credit_card_exp_date[M]", "value=1"); | |
510 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
511 | ||
512 | //Billing Info | |
513 | $this->type("billing_first_name", $firstName . "billing"); | |
514 | $this->type("billing_last_name", $lastName . "billing"); | |
515 | $this->type("billing_street_address-5", "15 Main St."); | |
516 | $this->type(" billing_city-5", "San Jose"); | |
517 | $this->select("billing_country_id-5", "value=1228"); | |
518 | $this->select("billing_state_province_id-5", "value=1004"); | |
519 | $this->type("billing_postal_code-5", "94129"); | |
225a8648 | 520 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
521 | |
522 | $this->click("_qf_Confirm_next-bottom"); | |
523 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
524 | ||
6a488035 | 525 | // Log in using webtestLogin() method |
6a488035 TO |
526 | $this->webtestLogin(); |
527 | ||
528 | //Find member | |
529 | $endDate = date('F jS, Y', strtotime(" +1 year -1 day")); | |
42daf119 | 530 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
531 | |
532 | $this->type("sort_name", "$organisationName"); | |
a1c7d42f CW |
533 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
534 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
535 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
536 | ||
537 | //View Membership Record | |
538 | $verifyMembershipData = array( | |
539 | 'Member' => $organisationName, | |
540 | 'Membership Type' => $membershipTypeTitle, | |
541 | 'Status' => 'New', | |
542 | 'End date' => $endDate, | |
543 | ); | |
544 | ||
545 | foreach ($verifyMembershipData as $label => $value) { | |
546 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
547 | preg_quote($value) | |
548 | ); | |
549 | } | |
550 | ||
42daf119 | 551 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
552 | |
553 | $this->type("sort_name", "$lastName, $firstName"); | |
a1c7d42f CW |
554 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
555 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
556 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
557 | ||
558 | //View Membership Record | |
559 | $verifyMembershipData = array( | |
560 | 'Member' => $name, | |
561 | 'Membership Type' => $membershipTypeTitle, | |
562 | 'Status' => 'New', | |
563 | 'End date' => $endDate, | |
564 | ); | |
565 | ||
566 | foreach ($verifyMembershipData as $label => $value) { | |
567 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
568 | preg_quote($value) | |
569 | ); | |
570 | } | |
571 | ||
572 | //logout | |
42daf119 | 573 | $this->webtestLogout(); |
6a488035 | 574 | |
b45c587e | 575 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); |
6a488035 | 576 | |
b21dd815 | 577 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]"); |
6a488035 TO |
578 | $this->type("email-5", $email); |
579 | $this->click('is_for_organization'); | |
580 | $this->type('onbehalf_organization_name', $organisationName); | |
581 | $this->type('onbehalf_phone-3-1', '2222-222222'); | |
582 | $this->type('onbehalf_email-3', $organisationName . '@example.com'); | |
583 | $this->type('onbehalf_street_address-3', '22A Excelsior Ave. Unit 1h'); | |
584 | $this->type('onbehalf_city-3', 'Driftwood'); | |
585 | $this->type('onbehalf_postal_code-3', '75653'); | |
586 | $this->select('onbehalf_country-3', "value=1228"); | |
587 | $this->select('onbehalf_state_province-3', "value=1061"); | |
588 | ||
589 | $this->type('first_name', $firstName); | |
590 | $this->type('last_name', $lastName); | |
73072f84 | 591 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
592 | |
593 | //Credit Card Info | |
594 | $this->select("credit_card_type", "value=Visa"); | |
595 | $this->select("credit_card_type", "label=Visa"); | |
596 | $this->type("credit_card_number", "4111111111111111"); | |
597 | $this->type("cvv2", "000"); | |
598 | $this->select("credit_card_exp_date[M]", "value=1"); | |
599 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
600 | ||
601 | //Billing Info | |
602 | $this->type("billing_first_name", $firstName . "billing"); | |
603 | $this->type("billing_last_name", $lastName . "billing"); | |
604 | $this->type("billing_street_address-5", "15 Main St."); | |
605 | $this->type(" billing_city-5", "San Jose"); | |
606 | $this->select("billing_country_id-5", "value=1228"); | |
607 | $this->select("billing_state_province_id-5", "value=1004"); | |
608 | $this->type("billing_postal_code-5", "94129"); | |
609 | ||
225a8648 | 610 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
611 | |
612 | $this->click("_qf_Confirm_next-bottom"); | |
613 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
614 | ||
615 | // Log in using webtestLogin() method | |
6a488035 TO |
616 | $this->webtestLogin(); |
617 | ||
618 | //Find member | |
619 | $endDate = date('F jS, Y', strtotime(" +2 year -1 day")); | |
42daf119 | 620 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
621 | |
622 | $this->type("sort_name", "$organisationName"); | |
a1c7d42f CW |
623 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
624 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
625 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
626 | ||
627 | //View Membership Record | |
628 | $verifyMembershipData = array( | |
629 | 'Member' => $organisationName, | |
630 | 'Membership Type' => $membershipTypeTitle, | |
631 | 'End date' => $endDate, | |
632 | ); | |
633 | ||
634 | foreach ($verifyMembershipData as $label => $value) { | |
635 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
636 | preg_quote($value) | |
637 | ); | |
638 | } | |
639 | ||
42daf119 | 640 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
641 | |
642 | $this->type("sort_name", "$lastName, $firstName"); | |
a1c7d42f CW |
643 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
644 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
645 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
646 | ||
647 | //View Membership Record | |
648 | $verifyMembershipData = array( | |
649 | 'Member' => $name, | |
650 | 'Membership Type' => $membershipTypeTitle, | |
651 | 'End date' => $endDate, | |
652 | ); | |
653 | ||
654 | foreach ($verifyMembershipData as $label => $value) { | |
655 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
656 | preg_quote($value) | |
657 | ); | |
658 | } | |
659 | } | |
96025800 | 660 | |
0b181bcb | 661 | public function testOnRecurringContributionAndMembershipRenewal() { |
662 | // Log in as admin | |
663 | $this->webtestLogin('admin'); | |
664 | ||
665 | $this->enableComponents('CiviMember'); | |
666 | ||
667 | // Log in as normal user | |
668 | $this->webtestLogin(); | |
669 | ||
670 | // Add membership Type | |
671 | $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse"); | |
672 | ||
673 | $this->click('link=Add Membership Type'); | |
674 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
675 | ||
676 | $title = substr(sha1(rand()), 0, 7); | |
677 | $membershipTypeTitle = "Membership Type $title"; | |
678 | $this->type('name', "Membership Type $title"); | |
679 | ||
680 | $this->select2('member_of_contact_id', 'Default Organization'); | |
681 | ||
682 | $this->type('minimum_fee', '100'); | |
683 | $this->select('financial_type_id', 'value=2'); | |
684 | $this->type('duration_interval', 1); | |
685 | $this->select('duration_unit', 'label=year'); | |
686 | $this->select('period_type', 'value=rolling'); | |
687 | $this->click('CIVICRM_QFID_1_auto_renew'); | |
688 | ||
689 | $this->click('_qf_MembershipType_upload-bottom'); | |
690 | $this->waitForElementPresent('link=Add Membership Type'); | |
691 | $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved."); | |
692 | ||
693 | $this->waitForElementPresent("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href"); | |
694 | $url = $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href"); | |
695 | $matches = array(); | |
696 | preg_match('/id=([0-9]+)/', $url, $matches); | |
697 | $membershipTypeId = $matches[1]; | |
698 | ||
699 | // Use default payment processor | |
700 | $processorName = 'Test Processor'; | |
701 | ||
702 | // create contribution page with randomized title and default params | |
703 | $hash = substr(sha1(rand()), 0, 7); | |
704 | $rand = 2 * rand(2, 50); | |
705 | $amountSection = FALSE; | |
706 | $payLater = FALSE; | |
707 | $onBehalf = FALSE; | |
708 | $pledges = FALSE; | |
709 | $recurring = FALSE; | |
710 | $memberships = FALSE; | |
711 | $memPriceSetId = NULL; | |
712 | $friend = FALSE; | |
713 | $profilePreId = NULL; | |
714 | $profilePostId = NULL; | |
715 | $premiums = FALSE; | |
716 | $widget = FALSE; | |
717 | $pcp = FALSE; | |
718 | ||
719 | $contributionTitle = "Title $hash"; | |
720 | $pageId = $this->webtestAddContributionPage($hash, | |
721 | $rand, | |
722 | $contributionTitle, | |
723 | array($processorName => 'Dummy'), | |
724 | $amountSection, | |
725 | $payLater, | |
726 | $onBehalf, | |
727 | $pledges, | |
728 | $recurring, | |
729 | $memberships, | |
730 | $memPriceSetId, | |
731 | $friend, | |
732 | $profilePreId, | |
733 | $profilePostId, | |
734 | $premiums, | |
735 | $widget, | |
736 | $pcp, | |
737 | TRUE | |
738 | ); | |
739 | ||
740 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_next'); | |
741 | ||
742 | //this contribution page for membership signup | |
743 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
744 | $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName); | |
745 | $this->check($xpath); | |
746 | ||
747 | //enable contribution amaount | |
748 | $this->click('amount_block_is_active'); | |
749 | $this->waitForElementPresent('amount_label'); | |
750 | $this->type('amount_label', 'Additional Contribution'); | |
751 | $this->click('is_allow_other_amount'); | |
752 | $this->type('min_amount', '10'); | |
753 | $this->type('max_amount', '1000'); | |
754 | ||
755 | // save | |
756 | $this->waitForElementPresent('_qf_Amount_submit_savenext'); | |
757 | $this->click('_qf_Amount_submit_savenext'); | |
758 | $this->waitForPageToLoad(); | |
759 | ||
760 | //enable membership block | |
761 | $this->waitForElementPresent("member_is_active"); | |
762 | $this->check("member_is_active"); | |
763 | $this->waitForElementPresent("new_title"); | |
764 | $this->type('new_title', 'Membership Levels'); | |
765 | $this->type('membership_type_label', 'Membership Levels'); | |
766 | $this->check("membership_type_$membershipTypeId"); | |
767 | $this->check("is_required"); | |
768 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
769 | ||
770 | //Scenario 1(a) - (is_separate_payment=FALSE + recurring contribution + non-renewal membership) on Amount page | |
771 | $this->click('link=Amounts'); | |
772 | $this->waitForElementPresent("is_recur"); | |
773 | $this->click('is_recur'); | |
774 | $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom'); | |
775 | $this->waitForElementPresent("is_recur"); | |
776 | $this->assertTrue($this->isTextPresent("You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution.")); | |
777 | ||
778 | //Scenario 1(b) - (is_separate_payment=FALSE + recurring contribution + non-renewal membership) on MembershipBlock page | |
779 | $this->click('link=Memberships'); | |
780 | $this->waitForElementPresent("is_separate_payment"); | |
781 | $this->click('is_separate_payment');//enable is_separate_payment | |
782 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
783 | $this->click('link=Amounts');//switch back to amount page | |
784 | $this->waitForElementPresent("is_recur"); | |
785 | $this->click('is_recur');//enable recurring contribution | |
786 | $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom'); | |
787 | $this->click('link=Memberships');//switch back to MembershipBlock page | |
788 | $this->waitForElementPresent("is_separate_payment"); | |
789 | $this->uncheck('is_separate_payment');//disable is_separate_payment | |
790 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
791 | $this->waitForElementPresent("is_separate_payment"); | |
792 | $this->assertTrue($this->isTextPresent("You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution")); | |
793 | ||
794 | //Scenario 2(a) - (is_separate_payment=TRUE + recurring contribution + auto-renewal membership) on MembershipBlock page | |
795 | $this->click('is_separate_payment');//enable is_separate_payment | |
796 | $this->select("auto_renew_$membershipTypeId", 'value=1');//choose auto-renew as optional | |
797 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
798 | $this->assertTrue($this->isTextPresent("You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page")); | |
799 | ||
800 | //Scenario 2(b) - (is_separate_payment=TRUE + recurring contribution + auto-renewal membership) on Amount page | |
801 | $this->click('link=Amounts');//switch back to amount page | |
802 | $this->waitForElementPresent("is_recur"); | |
803 | $this->uncheck('is_recur');//disable recurring contribution | |
804 | $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom'); | |
805 | $this->click('link=Memberships');//switch back to MembershipBlock page | |
806 | $this->waitForElementPresent("auto_renew_$membershipTypeId"); | |
807 | $this->select("auto_renew_$membershipTypeId", 'value=1');//choose auto-renew as optional | |
808 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
809 | $this->click('link=Amounts');//switch back to amount page | |
810 | $this->waitForElementPresent("is_recur"); | |
811 | $this->click('is_recur');//enable recurring contribution | |
812 | $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom'); | |
813 | $this->waitForElementPresent("is_recur"); | |
814 | $this->assertTrue($this->isTextPresent("You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page")); | |
815 | ||
816 | //Scenario 3 - Online Registration on | |
817 | // (is_separate_payment=TRUE + non-recurring Additional contribution + auto-renewal membership) setting | |
818 | $firstName = 'Eia' . substr(sha1(rand()), 0, 4); | |
819 | $lastName = 'Ande' . substr(sha1(rand()), 0, 4); | |
820 | $email = $firstName . '@test.com'; | |
821 | ||
822 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); | |
823 | ||
824 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]"); | |
825 | $this->waitForElementPresent("auto_renew"); | |
826 | $this->type("xpath=//div[@class='content other_amount-content']/input[@type='text']", '20'); | |
827 | $this->click("auto_renew"); | |
828 | ||
829 | //fill email | |
830 | $this->type('email-5', $email); | |
831 | ||
832 | //Credit Card Info | |
833 | $this->select("credit_card_type", "value=Visa"); | |
834 | $this->select("credit_card_type", "label=Visa"); | |
835 | $this->type("credit_card_number", "4111111111111111"); | |
836 | $this->type("cvv2", "000"); | |
837 | $this->select("credit_card_exp_date[M]", "value=1"); | |
838 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
839 | ||
840 | //Billing Info | |
841 | $this->type("billing_first_name", $firstName . "billing"); | |
842 | $this->type("billing_last_name", $lastName . "billing"); | |
843 | $this->type("billing_street_address-5", "15 Main St."); | |
844 | $this->type(" billing_city-5", "San Jose"); | |
845 | $this->select("billing_country_id-5", "value=1228"); | |
846 | $this->select("billing_state_province_id-5", "value=1004"); | |
847 | $this->type("billing_postal_code-5", "94129"); | |
848 | ||
849 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); | |
850 | $this->assertTrue($this->isTextPresent("I want this membership to be renewed automatically every 1 year(s).")); | |
851 | $this->click("_qf_Confirm_next-bottom"); | |
852 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
853 | ||
854 | $expectedParams = array( | |
855 | 'Pending' => array( | |
856 | 'total_amount' => 100.00), | |
857 | 'Completed' => array( | |
858 | 'total_amount' => 20.00, | |
859 | ), | |
860 | ); | |
861 | ||
862 | //Assert that additional contribution and auto-renewal membrship | |
863 | $membership = $this->webtest_civicrm_api("Membership", "get", array('membership_type_id' => $membershipTypeId)); | |
864 | $this->assertEquals($membership['count'], 1); | |
865 | $membershipId = $membership['id']; | |
866 | $this->assertEquals($membership['values'][$membershipId]['membership_name'], $membershipTypeTitle); | |
867 | $this->assertEquals($membership['values'][$membershipId]['status_id'], 1); | |
868 | ||
869 | //check if the membership created is set to reccuring | |
870 | $recurringContributionId = $membership['values'][$membershipId]['contribution_recur_id']; | |
871 | $recurringContribution = $this->webtest_civicrm_api("ContributionRecur", "get", array('id' => $recurringContributionId)); | |
872 | $this->assertEquals($recurringContribution['count'], 1); | |
873 | $this->assertEquals($recurringContribution['values'][$recurringContributionId]['auto_renew'], 1); | |
874 | $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_unit'], 'year'); | |
875 | $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_interval'], 1); | |
876 | ||
877 | $results = $this->webtest_civicrm_api("Contribution", "get", array('source' => array('LIKE' => "%$contributionTitle%"))); | |
878 | foreach ($results['values'] as $value) { | |
879 | $status = $value['contribution_status']; | |
880 | $this->assertEquals($value['total_amount'], $expectedParams[$status]['total_amount']); | |
881 | $this->webtest_civicrm_api("Contribution", "delete", array('id' => $value['contribution_id'])); | |
882 | } | |
883 | ||
884 | //Cleanup data before trying next combination | |
885 | $this->webtest_civicrm_api("Membership", "delete", array('id' => $membershipId)); | |
886 | $this->webtest_civicrm_api("ContributionRecur", "delete", array('id' => $recurringContributionId)); | |
887 | ||
888 | //Scenario 4 - Online Registration on | |
889 | // (is_separate_payment=TRUE + recurring Additional contribution + non auto-renewal membership) setting | |
890 | $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId"); | |
891 | $this->waitForElementPresent("auto_renew_$membershipTypeId"); | |
892 | $this->select("auto_renew_$membershipTypeId", 'value=0'); | |
893 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
894 | $this->click('link=Amounts');//switch back to amount page | |
895 | $this->waitForElementPresent("is_recur"); | |
896 | $this->click('is_recur');//disable recurring contribution | |
897 | $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom'); | |
898 | ||
899 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); | |
900 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]"); | |
901 | $this->type("xpath=//div[@class='content other_amount-content']/input[@type='text']", '30'); | |
902 | $this->click("is_recur"); | |
903 | ||
904 | //Credit Card Info | |
905 | $this->select("credit_card_type", "value=Visa"); | |
906 | $this->select("credit_card_type", "label=Visa"); | |
907 | $this->type("credit_card_number", "4111111111111111"); | |
908 | $this->type("cvv2", "000"); | |
909 | $this->select("credit_card_exp_date[M]", "value=1"); | |
910 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
911 | ||
912 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); | |
913 | $this->assertTrue($this->isTextPresent("I want to contribute this amount every month.")); | |
914 | $this->click("_qf_Confirm_next-bottom"); | |
915 | sleep(10); | |
916 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
917 | ||
918 | $expectedParams = array( | |
919 | 'Pending' => array( | |
920 | 'total_amount' => 30.00), | |
921 | 'Completed' => array( | |
922 | 'total_amount' => 100.00, | |
923 | ), | |
924 | ); | |
925 | ||
926 | //Assert that additional contribution and auto-renewal membrship | |
927 | $membership = $this->webtest_civicrm_api("Membership", "get", array('membership_type_id' => $membershipTypeId)); | |
928 | $this->assertEquals($membership['count'], 1); | |
929 | $membershipId = $membership['id']; | |
930 | $this->assertEquals($membership['values'][$membershipId]['membership_name'], $membershipTypeTitle); | |
931 | $this->assertEquals($membership['values'][$membershipId]['status_id'], 1); | |
932 | $this->assertEquals($membership['values'][$membershipId]['source'], "Online Contribution: $contributionTitle"); | |
933 | ||
934 | $results = $this->webtest_civicrm_api("Contribution", "get", array('source' => array('LIKE' => "%$contributionTitle%"))); | |
935 | foreach ($results['values'] as $value) { | |
936 | $status = $value['contribution_status']; | |
937 | $this->assertEquals($value['total_amount'], $expectedParams[$status]['total_amount']); | |
938 | if ($status == 'Pending') { | |
939 | $recurringContributionId = $value['contribution_recur_id']; | |
940 | $recurringContribution = $this->webtest_civicrm_api("ContributionRecur", "get", array('id' => $recurringContributionId)); | |
941 | $this->assertEquals($recurringContribution['count'], 1); | |
942 | $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_unit'], 'month'); | |
943 | $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_interval'], 1); | |
944 | } | |
945 | $this->webtest_civicrm_api("Contribution", "delete", array('id' => $value['contribution_id'])); | |
946 | } | |
947 | } | |
948 | ||
6a488035 | 949 | } |