Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
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 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
b45c587e CW |
35 | /** |
36 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
37 | */ | |
6a488035 TO |
38 | function testOnlineMembershipRenew() { |
39 | // a random 7-char string and an even number to make this pass unique | |
40 | $hash = substr(sha1(rand()), 0, 7); | |
41 | $rand = 2 * rand(2, 50); | |
42 | ||
6a488035 TO |
43 | // Log in using webtestLogin() method |
44 | $this->webtestLogin(); | |
45 | ||
46 | // We need a payment processor | |
47 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
48 | $this->webtestAddPaymentProcessor($processorName); | |
49 | ||
42daf119 | 50 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next"); |
6a488035 TO |
51 | // this contribution page for membership signup |
52 | // select newly created processor | |
53 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
54 | $this->assertTrue($this->isTextPresent($processorName)); | |
55 | $this->check($xpath); | |
56 | ||
57 | // save | |
58 | $this->waitForElementPresent("_qf_Amount_next"); | |
b45c587e | 59 | $this->clickLink('_qf_Amount_next'); |
6a488035 TO |
60 | |
61 | // go to Membership block | |
62 | $this->click('css=#tab_membership a'); | |
63 | $this->waitForElementPresent("member_is_active"); | |
64 | $this->check("member_is_active"); | |
65 | ||
66 | $this->waitForElementPresent("new_title"); | |
67 | if ($this->isElementPresent("member_price_set_id")) { | |
68 | $this->waitForElementPresent("member_price_set_id"); | |
69 | $this->select("member_price_set_id", "label=- none -"); | |
70 | } | |
71 | ||
72 | $this->waitForElementPresent("membership_type-block"); | |
73 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
74 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
75 | $this->click("_qf_MembershipBlock_next-bottom"); | |
76 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
77 | ||
78 | // go to Profiles | |
79 | $this->click('css=#tab_custom a'); | |
80 | ||
81 | // fill in Profiles | |
82 | $this->waitForElementPresent('custom_pre_id'); | |
83 | $this->select('custom_pre_id', 'value=1'); | |
84 | ||
85 | // save | |
86 | $this->click('_qf_Custom_upload_done'); | |
87 | $this->waitForPageToLoad(); | |
88 | ||
89 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
42daf119 CW |
90 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
91 | $email = $firstName . "@example.com"; | |
6a488035 TO |
92 | |
93 | //logout | |
42daf119 | 94 | $this->webtestLogout(); |
6a488035 TO |
95 | |
96 | //Go to online membership signup page | |
42daf119 | 97 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
98 | |
99 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); | |
100 | ||
101 | //Type first name and last name and email | |
102 | $this->type("first_name", $firstName); | |
103 | $this->type("last_name", $lastName); | |
104 | $this->type("email-5", $email); | |
105 | ||
106 | //Credit Card Info | |
107 | $this->select("credit_card_type", "value=Visa"); | |
108 | $this->select("credit_card_type", "label=Visa"); | |
109 | $this->type("credit_card_number", "4111111111111111"); | |
110 | $this->type("cvv2", "000"); | |
111 | $this->select("credit_card_exp_date[M]", "value=1"); | |
112 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
113 | ||
114 | //Billing Info | |
115 | $this->type("billing_first_name", $firstName . "billing"); | |
116 | $this->type("billing_last_name", $lastName . "billing"); | |
117 | $this->type("billing_street_address-5", "15 Main St."); | |
118 | $this->type(" billing_city-5", "San Jose"); | |
119 | $this->select("billing_country_id-5", "value=1228"); | |
120 | $this->select("billing_state_province_id-5", "value=1004"); | |
121 | $this->type("billing_postal_code-5", "94129"); | |
122 | ||
123 | $this->click("_qf_Main_upload-bottom"); | |
124 | ||
125 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
126 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
127 | ||
128 | $this->click("_qf_Confirm_next-bottom"); | |
129 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
130 | ||
131 | // Log in using webtestLogin() method | |
6a488035 TO |
132 | $this->webtestLogin(); |
133 | //Find Member | |
42daf119 | 134 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
135 | |
136 | $this->type("sort_name", "$firstName $lastName"); | |
137 | $this->click("_qf_Search_refresh"); | |
138 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
139 | ||
140 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
141 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
142 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
143 | ||
144 | //View Membership Record | |
145 | $verifyMembershipData = array( | |
146 | 'Member' => $firstName . ' ' . $lastName, | |
147 | 'Membership Type' => 'Student', | |
148 | 'Status' => 'New', | |
149 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
150 | ); | |
151 | foreach ($verifyMembershipData as $label => $value) { | |
152 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
153 | preg_quote($value) | |
154 | ); | |
155 | } | |
156 | ||
157 | //logout | |
42daf119 | 158 | $this->webtestLogout(); |
6a488035 | 159 | |
42daf119 | 160 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
161 | |
162 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); | |
163 | ||
164 | //Type first name and last name and email | |
165 | $this->type("first_name", $firstName); | |
166 | $this->type("last_name", $lastName); | |
167 | $this->type("email-5", $email); | |
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 | ||
186 | $this->click("_qf_Main_upload-bottom"); | |
187 | ||
188 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
189 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
190 | $this->click("_qf_Confirm_next-bottom"); | |
191 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
192 | ||
6a488035 TO |
193 | $this->webtestLogin(); |
194 | //Find Member | |
42daf119 | 195 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
196 | |
197 | $this->type("sort_name", "$firstName $lastName"); | |
198 | $this->click("_qf_Search_refresh"); | |
199 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
200 | ||
201 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
202 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
203 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
204 | ||
205 | //View Membership Record | |
206 | $verifyMembershipData = array( | |
207 | 'Member' => $firstName . ' ' . $lastName, | |
208 | 'Membership Type' => 'Student', | |
209 | 'Status' => 'New', | |
210 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
211 | ); | |
212 | foreach ($verifyMembershipData as $label => $value) { | |
213 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
214 | preg_quote($value) | |
215 | ); | |
216 | } | |
217 | } | |
218 | ||
b45c587e CW |
219 | /** |
220 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
221 | */ | |
6a488035 TO |
222 | function testOnlineMembershipRenewChangeType() { |
223 | // a random 7-char string and an even number to make this pass unique | |
224 | $hash = substr(sha1(rand()), 0, 7); | |
225 | $rand = 2 * rand(2, 50); | |
226 | ||
6a488035 TO |
227 | // Log in using webtestLogin() method |
228 | $this->webtestLogin(); | |
229 | ||
230 | // We need a payment processor | |
231 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
232 | $this->webtestAddPaymentProcessor($processorName); | |
233 | ||
42daf119 | 234 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next'); |
6a488035 TO |
235 | |
236 | //this contribution page for membership signup | |
237 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
238 | $this->assertTrue($this->isTextPresent($processorName)); | |
239 | $this->check($xpath); | |
240 | ||
241 | // save | |
242 | $this->waitForElementPresent('_qf_Amount_next'); | |
243 | $this->click('_qf_Amount_next'); | |
244 | $this->waitForPageToLoad(); | |
245 | ||
246 | // go to Membership block | |
247 | $this->click('css=#tab_membership a'); | |
248 | $this->waitForElementPresent("member_is_active"); | |
249 | $this->check("member_is_active"); | |
250 | ||
251 | $this->waitForElementPresent("new_title"); | |
252 | if ($this->isElementPresent("member_price_set_id")) { | |
253 | $this->waitForElementPresent("member_price_set_id"); | |
254 | $this->select("member_price_set_id", "label=- none -"); | |
255 | } | |
256 | ||
257 | $this->waitForElementPresent("membership_type-block"); | |
258 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
259 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
260 | $this->click("_qf_MembershipBlock_next-bottom"); | |
261 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
262 | ||
263 | // go to Profiles | |
264 | $this->click('css=#tab_custom a'); | |
265 | ||
266 | // fill in Profiles | |
267 | $this->waitForElementPresent('custom_pre_id'); | |
268 | $this->select('custom_pre_id', 'value=1'); | |
269 | ||
270 | // save | |
271 | $this->click('_qf_Custom_upload_done'); | |
272 | $this->waitForPageToLoad(); | |
273 | ||
274 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
275 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
276 | ||
277 | //Go to online membership signup page | |
42daf119 | 278 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
279 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'General')]"); |
280 | //Type first name and last name | |
281 | $this->type("first_name", $firstName); | |
282 | $this->type("last_name", $lastName); | |
283 | ||
284 | //Credit Card Info | |
285 | $this->select("credit_card_type", "value=Visa"); | |
286 | $this->select("credit_card_type", "label=Visa"); | |
287 | $this->type("credit_card_number", "4111111111111111"); | |
288 | $this->type("cvv2", "000"); | |
289 | $this->select("credit_card_exp_date[M]", "value=1"); | |
290 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
291 | ||
292 | //Billing Info | |
293 | $this->type("billing_first_name", $firstName . "billing"); | |
294 | $this->type("billing_last_name", $lastName . "billing"); | |
295 | $this->type("billing_street_address-5", "15 Main St."); | |
296 | $this->type(" billing_city-5", "San Jose"); | |
297 | $this->select("billing_country_id-5", "value=1228"); | |
298 | $this->select("billing_state_province_id-5", "value=1004"); | |
299 | $this->type("billing_postal_code-5", "94129"); | |
300 | ||
301 | $this->click("_qf_Main_upload-bottom"); | |
302 | ||
303 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
304 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
305 | ||
306 | $this->click("_qf_Confirm_next-bottom"); | |
307 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
308 | ||
309 | //Find Member | |
42daf119 | 310 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
311 | |
312 | $this->type("sort_name", "$firstName $lastName"); | |
313 | $this->click("_qf_Search_refresh"); | |
314 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
315 | ||
316 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
317 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
318 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
319 | ||
320 | $matches = array(); | |
321 | preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); | |
322 | $membershipCreatedId = $matches[1]; | |
323 | ||
324 | $memberSince = date('F jS, Y'); | |
325 | ||
326 | //View Membership Record | |
327 | $verifyMembershipData = array( | |
328 | 'Member' => $firstName . ' ' . $lastName, | |
329 | 'Membership Type' => 'General', | |
330 | 'Status' => 'New', | |
331 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
332 | ); | |
333 | foreach ($verifyMembershipData as $label => $value) { | |
334 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
335 | preg_quote($value) | |
336 | ); | |
337 | } | |
42daf119 | 338 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
339 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
340 | ||
341 | //Credit Card Info | |
342 | $this->select("credit_card_type", "value=Visa"); | |
343 | $this->select("credit_card_type", "label=Visa"); | |
344 | $this->type("credit_card_number", "4111111111111111"); | |
345 | $this->type("cvv2", "000"); | |
346 | $this->select("credit_card_exp_date[M]", "value=1"); | |
347 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
348 | $this->click("_qf_Main_upload-bottom"); | |
349 | ||
350 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
351 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
352 | $this->click("_qf_Confirm_next-bottom"); | |
353 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
354 | ||
355 | //Find Member | |
42daf119 | 356 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
357 | |
358 | $this->type("sort_name", "$firstName $lastName"); | |
359 | $this->click("_qf_Search_refresh"); | |
360 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
361 | ||
362 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
363 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
364 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
365 | ||
366 | $matches = array(); | |
367 | preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); | |
368 | $membershipRenewedId = $matches[1]; | |
369 | ||
370 | //View Membership Record | |
371 | $verifyMembershipData = array( | |
372 | 'Member' => $firstName . ' ' . $lastName, | |
373 | 'Membership Type' => 'Student', | |
374 | 'Status' => 'New', | |
375 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
376 | 'Member Since' => $memberSince, | |
377 | ); | |
378 | foreach ($verifyMembershipData as $label => $value) { | |
379 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
380 | preg_quote($value) | |
381 | ); | |
382 | } | |
383 | $this->assertEquals($membershipCreatedId, $membershipRenewedId); | |
384 | } | |
385 | ||
386 | function testUpdateInheritedMembershipOnBehalfOfRenewal() { | |
42daf119 CW |
387 | // Log in as admin |
388 | $this->webtestLogin('admin'); | |
389 | ||
390 | $this->enableComponents('CiviMember'); | |
6a488035 | 391 | |
42daf119 CW |
392 | //check for online contribution and profile listings permissions |
393 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); | |
394 | $this->changePermissions($permissions); | |
395 | ||
396 | // Log in as normal user | |
6a488035 TO |
397 | $this->webtestLogin(); |
398 | ||
42daf119 | 399 | $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); |
6a488035 TO |
400 | |
401 | $title = substr(sha1(rand()), 0, 7); | |
402 | $this->type('organization_name', "Organization $title"); | |
403 | $this->type('email_1_email', "$title@org.com"); | |
404 | $this->click('_qf_Contact_upload_view'); | |
405 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
406 | ||
407 | $this->assertTrue($this->isTextPresent("Organization $title has been created.")); | |
408 | ||
071a6d2e | 409 | $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse"); |
6a488035 TO |
410 | |
411 | $this->click('link=Add Membership Type'); | |
412 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
413 | ||
414 | $membershipTypeTitle = "Membership Type $title"; | |
415 | $this->type('name', "Membership Type $title"); | |
416 | ||
417 | $this->type('member_of_contact', $title); | |
418 | $this->click('member_of_contact'); | |
419 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
420 | $this->click("css=div.ac_results-inner li"); | |
421 | ||
422 | $this->type('minimum_fee', '100'); | |
423 | $this->select( 'financial_type_id', 'value=2' ); | |
424 | $this->type('duration_interval', 1); | |
425 | $this->select('duration_unit', 'label=year'); | |
426 | $this->select('period_type', 'label=rolling'); | |
427 | ||
428 | $this->removeSelection('relationship_type_id', 'label=- select -'); | |
429 | $this->addSelection('relationship_type_id', 'label=Employer of'); | |
430 | ||
431 | $this->click('_qf_MembershipType_upload-bottom'); | |
432 | $this->waitForElementPresent('link=Add Membership Type'); | |
433 | $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); | |
434 | ||
435 | $url = $this->getAttribute("xpath=//div[@id='membership_type']//div[@class='dataTables_wrapper']//table/tbody//tr/td[1][text()='{$membershipTypeTitle}']/../td[12]/span/a[3][text()='Delete']/@href"); | |
436 | ||
437 | $matches = array(); | |
438 | preg_match('/id=([0-9]+)/', $url, $matches); | |
439 | $membershipTypeId = $matches[1]; | |
440 | ||
441 | // We need a payment processor | |
442 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
443 | ||
6a488035 | 444 | // create contribution page with randomized title and default params |
42daf119 CW |
445 | $hash = substr(sha1(rand()), 0, 7); |
446 | $rand = 2 * rand(2, 50); | |
6a488035 | 447 | $amountSection = FALSE; |
42daf119 CW |
448 | $payLater = FALSE; |
449 | $onBehalf = FALSE; | |
450 | $pledges = FALSE; | |
451 | $recurring = FALSE; | |
452 | $memberships = FALSE; | |
6a488035 | 453 | $memPriceSetId = NULL; |
42daf119 CW |
454 | $friend = FALSE; |
455 | $profilePreId = 1; | |
6a488035 | 456 | $profilePostId = NULL; |
42daf119 CW |
457 | $premiums = FALSE; |
458 | $widget = FALSE; | |
459 | $pcp = FALSE; | |
6a488035 TO |
460 | |
461 | $contributionTitle = "Title $hash"; | |
462 | $pageId = $this->webtestAddContributionPage($hash, | |
463 | $rand, | |
464 | $contributionTitle, | |
465 | array($processorName => 'Dummy'), | |
466 | $amountSection, | |
467 | $payLater, | |
468 | $onBehalf, | |
469 | $pledges, | |
470 | $recurring, | |
471 | $memberships, | |
472 | $memPriceSetId, | |
473 | $friend, | |
474 | $profilePreId, | |
475 | $profilePostId, | |
476 | $premiums, | |
477 | $widget, | |
478 | $pcp, | |
479 | TRUE | |
480 | ); | |
481 | ||
482 | $hash = substr(sha1(rand()), 0, 7); | |
071a6d2e | 483 | $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id=$pageId"); |
6a488035 TO |
484 | |
485 | $this->click('link=Title'); | |
486 | $this->waitForElementPresent('_qf_Settings_cancel-bottom'); | |
487 | $this->click('is_organization'); | |
488 | $this->select('onbehalf_profile_id', "value=9"); | |
489 | $this->type('for_organization', "On behalf $hash"); | |
490 | $this->click('_qf_Settings_next-bottom'); | |
491 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
492 | ||
493 | $this->click('link=Memberships'); | |
494 | $this->waitForElementPresent('_qf_MembershipBlock_cancel-bottom'); | |
495 | $this->click('member_is_active'); | |
496 | $this->type('new_title', "Title - New Membership $hash"); | |
497 | $this->type('renewal_title', "Title - Renewals $hash"); | |
498 | $this->click("membership_type_{$membershipTypeId}"); | |
499 | $this->click('is_required'); | |
500 | $this->click('_qf_MembershipBlock_next-bottom'); | |
501 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
502 | ||
503 | //logout | |
42daf119 | 504 | $this->webtestLogout(); |
6a488035 TO |
505 | |
506 | //get Url for Live Contribution Page | |
071a6d2e | 507 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom'); |
6a488035 | 508 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); |
42daf119 CW |
509 | $firstName = 'Eia' . substr(sha1(rand()), 0, 4); |
510 | $lastName = 'Ande' . substr(sha1(rand()), 0, 4); | |
511 | $name = $firstName . ' ' . $lastName; | |
6a488035 TO |
512 | $organisationName = 'TestOrg' . substr(sha1(rand()), 0, 7); |
513 | ||
514 | $email = $firstName . '@example.com'; | |
515 | $this->type('email-5', $email); | |
516 | $this->click('is_for_organization'); | |
517 | $this->type('onbehalf_organization_name', $organisationName); | |
518 | $this->type('onbehalf_phone-3-1', '2222-222222'); | |
519 | $this->type('onbehalf_email-3', $organisationName . '@example.com'); | |
520 | $this->type('onbehalf_street_address-3', '54A Excelsior Ave. Apt 1C'); | |
521 | $this->type('onbehalf_city-3', 'Driftwood'); | |
522 | $this->type('onbehalf_postal_code-3', '75653'); | |
523 | $this->select('onbehalf_country-3', "value=1228"); | |
524 | $this->select('onbehalf_state_province-3', "value=1061"); | |
525 | ||
526 | $this->type('first_name', $firstName); | |
527 | $this->type('last_name', $lastName); | |
528 | ||
529 | //Credit Card Info | |
530 | $this->select("credit_card_type", "value=Visa"); | |
531 | $this->select("credit_card_type", "label=Visa"); | |
532 | $this->type("credit_card_number", "4111111111111111"); | |
533 | $this->type("cvv2", "000"); | |
534 | $this->select("credit_card_exp_date[M]", "value=1"); | |
535 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
536 | ||
537 | //Billing Info | |
538 | $this->type("billing_first_name", $firstName . "billing"); | |
539 | $this->type("billing_last_name", $lastName . "billing"); | |
540 | $this->type("billing_street_address-5", "15 Main St."); | |
541 | $this->type(" billing_city-5", "San Jose"); | |
542 | $this->select("billing_country_id-5", "value=1228"); | |
543 | $this->select("billing_state_province_id-5", "value=1004"); | |
544 | $this->type("billing_postal_code-5", "94129"); | |
545 | $this->click("_qf_Main_upload-bottom"); | |
546 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
547 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
548 | ||
549 | $this->click("_qf_Confirm_next-bottom"); | |
550 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
551 | ||
552 | ||
553 | // Log in using webtestLogin() method | |
6a488035 TO |
554 | $this->webtestLogin(); |
555 | ||
556 | //Find member | |
557 | $endDate = date('F jS, Y', strtotime(" +1 year -1 day")); | |
42daf119 | 558 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
559 | |
560 | $this->type("sort_name", "$organisationName"); | |
561 | $this->click("_qf_Search_refresh"); | |
562 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
563 | ||
564 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
565 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
566 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
567 | ||
568 | //View Membership Record | |
569 | $verifyMembershipData = array( | |
570 | 'Member' => $organisationName, | |
571 | 'Membership Type' => $membershipTypeTitle, | |
572 | 'Status' => 'New', | |
573 | 'End date' => $endDate, | |
574 | ); | |
575 | ||
576 | foreach ($verifyMembershipData as $label => $value) { | |
577 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
578 | preg_quote($value) | |
579 | ); | |
580 | } | |
581 | ||
42daf119 | 582 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
583 | |
584 | $this->type("sort_name", "$lastName, $firstName"); | |
585 | $this->click("_qf_Search_refresh"); | |
586 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
587 | ||
588 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
589 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
590 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
591 | ||
592 | //View Membership Record | |
593 | $verifyMembershipData = array( | |
594 | 'Member' => $name, | |
595 | 'Membership Type' => $membershipTypeTitle, | |
596 | 'Status' => 'New', | |
597 | 'End date' => $endDate, | |
598 | ); | |
599 | ||
600 | foreach ($verifyMembershipData as $label => $value) { | |
601 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
602 | preg_quote($value) | |
603 | ); | |
604 | } | |
605 | ||
606 | //logout | |
42daf119 | 607 | $this->webtestLogout(); |
6a488035 | 608 | |
b45c587e | 609 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); |
6a488035 TO |
610 | |
611 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); | |
612 | $this->type("email-5", $email); | |
613 | $this->click('is_for_organization'); | |
614 | $this->type('onbehalf_organization_name', $organisationName); | |
615 | $this->type('onbehalf_phone-3-1', '2222-222222'); | |
616 | $this->type('onbehalf_email-3', $organisationName . '@example.com'); | |
617 | $this->type('onbehalf_street_address-3', '22A Excelsior Ave. Unit 1h'); | |
618 | $this->type('onbehalf_city-3', 'Driftwood'); | |
619 | $this->type('onbehalf_postal_code-3', '75653'); | |
620 | $this->select('onbehalf_country-3', "value=1228"); | |
621 | $this->select('onbehalf_state_province-3', "value=1061"); | |
622 | ||
623 | $this->type('first_name', $firstName); | |
624 | $this->type('last_name', $lastName); | |
625 | ||
626 | //Credit Card Info | |
627 | $this->select("credit_card_type", "value=Visa"); | |
628 | $this->select("credit_card_type", "label=Visa"); | |
629 | $this->type("credit_card_number", "4111111111111111"); | |
630 | $this->type("cvv2", "000"); | |
631 | $this->select("credit_card_exp_date[M]", "value=1"); | |
632 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
633 | ||
634 | //Billing Info | |
635 | $this->type("billing_first_name", $firstName . "billing"); | |
636 | $this->type("billing_last_name", $lastName . "billing"); | |
637 | $this->type("billing_street_address-5", "15 Main St."); | |
638 | $this->type(" billing_city-5", "San Jose"); | |
639 | $this->select("billing_country_id-5", "value=1228"); | |
640 | $this->select("billing_state_province_id-5", "value=1004"); | |
641 | $this->type("billing_postal_code-5", "94129"); | |
642 | ||
643 | $this->click("_qf_Main_upload-bottom"); | |
644 | ||
645 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
646 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
647 | ||
648 | $this->click("_qf_Confirm_next-bottom"); | |
649 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
650 | ||
651 | // Log in using webtestLogin() method | |
6a488035 TO |
652 | $this->webtestLogin(); |
653 | ||
654 | //Find member | |
655 | $endDate = date('F jS, Y', strtotime(" +2 year -1 day")); | |
42daf119 | 656 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
657 | |
658 | $this->type("sort_name", "$organisationName"); | |
659 | $this->click("_qf_Search_refresh"); | |
660 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
661 | ||
662 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
663 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
664 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
665 | ||
666 | //View Membership Record | |
667 | $verifyMembershipData = array( | |
668 | 'Member' => $organisationName, | |
669 | 'Membership Type' => $membershipTypeTitle, | |
670 | 'End date' => $endDate, | |
671 | ); | |
672 | ||
673 | foreach ($verifyMembershipData as $label => $value) { | |
674 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
675 | preg_quote($value) | |
676 | ); | |
677 | } | |
678 | ||
42daf119 | 679 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
680 | |
681 | $this->type("sort_name", "$lastName, $firstName"); | |
682 | $this->click("_qf_Search_refresh"); | |
683 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
684 | ||
685 | $this->waitForElementPresent('css=#memberSearch table tbody tr td span a.action-item-first'); | |
686 | $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); | |
687 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
688 | ||
689 | //View Membership Record | |
690 | $verifyMembershipData = array( | |
691 | 'Member' => $name, | |
692 | 'Membership Type' => $membershipTypeTitle, | |
693 | 'End date' => $endDate, | |
694 | ); | |
695 | ||
696 | foreach ($verifyMembershipData as $label => $value) { | |
697 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
698 | preg_quote($value) | |
699 | ); | |
700 | } | |
701 | } | |
702 | } | |
703 |