Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 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 | */ | |
6a488035 TO |
41 | function testOnlineMembershipRenew() { |
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 | ||
49 | // We need a payment processor | |
50 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
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")) { |
76e86fd8 CW |
72 | $this->waitForElementPresent("member_price_set_id"); |
73 | ||
6a488035 TO |
74 | $this->select("member_price_set_id", "label=- none -"); |
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 | |
6a488035 TO |
104 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
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"); | |
132 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
133 | ||
134 | // Log in using webtestLogin() method | |
6a488035 TO |
135 | $this->webtestLogin(); |
136 | //Find Member | |
42daf119 | 137 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
138 | |
139 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
140 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
141 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
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); | |
73072f84 | 168 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
169 | |
170 | //Credit Card Info | |
171 | $this->select("credit_card_type", "value=Visa"); | |
172 | $this->select("credit_card_type", "label=Visa"); | |
173 | $this->type("credit_card_number", "4111111111111111"); | |
174 | $this->type("cvv2", "000"); | |
175 | $this->select("credit_card_exp_date[M]", "value=1"); | |
176 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
177 | ||
178 | //Billing Info | |
179 | $this->type("billing_first_name", $firstName . "billing"); | |
180 | $this->type("billing_last_name", $lastName . "billing"); | |
181 | $this->type("billing_street_address-5", "15 Main St."); | |
182 | $this->type(" billing_city-5", "San Jose"); | |
183 | $this->select("billing_country_id-5", "value=1228"); | |
184 | $this->select("billing_state_province_id-5", "value=1004"); | |
185 | $this->type("billing_postal_code-5", "94129"); | |
186 | ||
225a8648 | 187 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
188 | $this->click("_qf_Confirm_next-bottom"); |
189 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
190 | ||
6a488035 TO |
191 | $this->webtestLogin(); |
192 | //Find Member | |
42daf119 | 193 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
194 | |
195 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
196 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
197 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
198 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
199 | ||
200 | //View Membership Record | |
201 | $verifyMembershipData = array( | |
202 | 'Member' => $firstName . ' ' . $lastName, | |
203 | 'Membership Type' => 'Student', | |
204 | 'Status' => 'New', | |
205 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
206 | ); | |
207 | foreach ($verifyMembershipData as $label => $value) { | |
208 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
209 | preg_quote($value) | |
210 | ); | |
211 | } | |
212 | } | |
213 | ||
b45c587e CW |
214 | /** |
215 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
216 | */ | |
6a488035 TO |
217 | function testOnlineMembershipRenewChangeType() { |
218 | // a random 7-char string and an even number to make this pass unique | |
219 | $hash = substr(sha1(rand()), 0, 7); | |
220 | $rand = 2 * rand(2, 50); | |
221 | ||
6a488035 TO |
222 | // Log in using webtestLogin() method |
223 | $this->webtestLogin(); | |
224 | ||
225 | // We need a payment processor | |
226 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
227 | $this->webtestAddPaymentProcessor($processorName); | |
228 | ||
42daf119 | 229 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next'); |
6a488035 TO |
230 | |
231 | //this contribution page for membership signup | |
232 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
2ac4a694 | 233 | $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName); |
6a488035 TO |
234 | $this->check($xpath); |
235 | ||
236 | // save | |
237 | $this->waitForElementPresent('_qf_Amount_next'); | |
238 | $this->click('_qf_Amount_next'); | |
239 | $this->waitForPageToLoad(); | |
240 | ||
241 | // go to Membership block | |
242 | $this->click('css=#tab_membership a'); | |
243 | $this->waitForElementPresent("member_is_active"); | |
244 | $this->check("member_is_active"); | |
76e86fd8 | 245 | |
6a488035 TO |
246 | $this->waitForElementPresent("new_title"); |
247 | if ($this->isElementPresent("member_price_set_id")) { | |
76e86fd8 CW |
248 | $this->waitForElementPresent("member_price_set_id"); |
249 | ||
6a488035 TO |
250 | $this->select("member_price_set_id", "label=- none -"); |
251 | } | |
76e86fd8 | 252 | |
6a488035 TO |
253 | $this->waitForElementPresent("membership_type-block"); |
254 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
255 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
256 | $this->click("_qf_MembershipBlock_next-bottom"); | |
257 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
76e86fd8 | 258 | |
6a488035 TO |
259 | // go to Profiles |
260 | $this->click('css=#tab_custom a'); | |
261 | ||
262 | // fill in Profiles | |
263 | $this->waitForElementPresent('custom_pre_id'); | |
73072f84 | 264 | $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1'); |
6a488035 TO |
265 | |
266 | // save | |
267 | $this->click('_qf_Custom_upload_done'); | |
268 | $this->waitForPageToLoad(); | |
269 | ||
270 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
271 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
272 | ||
273 | //Go to online membership signup page | |
42daf119 | 274 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
275 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'General')]"); |
276 | //Type first name and last name | |
277 | $this->type("first_name", $firstName); | |
278 | $this->type("last_name", $lastName); | |
279 | ||
73072f84 | 280 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
281 | //Credit Card Info |
282 | $this->select("credit_card_type", "value=Visa"); | |
283 | $this->select("credit_card_type", "label=Visa"); | |
284 | $this->type("credit_card_number", "4111111111111111"); | |
285 | $this->type("cvv2", "000"); | |
286 | $this->select("credit_card_exp_date[M]", "value=1"); | |
287 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
288 | ||
289 | //Billing Info | |
290 | $this->type("billing_first_name", $firstName . "billing"); | |
291 | $this->type("billing_last_name", $lastName . "billing"); | |
292 | $this->type("billing_street_address-5", "15 Main St."); | |
293 | $this->type(" billing_city-5", "San Jose"); | |
294 | $this->select("billing_country_id-5", "value=1228"); | |
295 | $this->select("billing_state_province_id-5", "value=1004"); | |
296 | $this->type("billing_postal_code-5", "94129"); | |
297 | ||
225a8648 | 298 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
299 | |
300 | $this->click("_qf_Confirm_next-bottom"); | |
301 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
302 | ||
303 | //Find Member | |
42daf119 | 304 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
305 | |
306 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
307 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
308 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
309 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
310 | ||
a471a3b6 | 311 | $membershipCreatedId = $this->urlArg('id'); |
6a488035 TO |
312 | |
313 | $memberSince = date('F jS, Y'); | |
314 | ||
315 | //View Membership Record | |
316 | $verifyMembershipData = array( | |
317 | 'Member' => $firstName . ' ' . $lastName, | |
318 | 'Membership Type' => 'General', | |
319 | 'Status' => 'New', | |
320 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
321 | ); | |
322 | foreach ($verifyMembershipData as $label => $value) { | |
323 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
324 | preg_quote($value) | |
325 | ); | |
326 | } | |
42daf119 | 327 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
328 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
329 | ||
330 | //Credit Card Info | |
331 | $this->select("credit_card_type", "value=Visa"); | |
332 | $this->select("credit_card_type", "label=Visa"); | |
333 | $this->type("credit_card_number", "4111111111111111"); | |
334 | $this->type("cvv2", "000"); | |
335 | $this->select("credit_card_exp_date[M]", "value=1"); | |
336 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
225a8648 | 337 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
338 | $this->click("_qf_Confirm_next-bottom"); |
339 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
340 | ||
341 | //Find Member | |
42daf119 | 342 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
343 | |
344 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
345 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
346 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
347 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
348 | ||
a471a3b6 | 349 | $membershipRenewedId = $this->urlArg('id'); |
6a488035 TO |
350 | |
351 | //View Membership Record | |
352 | $verifyMembershipData = array( | |
353 | 'Member' => $firstName . ' ' . $lastName, | |
354 | 'Membership Type' => 'Student', | |
355 | 'Status' => 'New', | |
356 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
357 | 'Member Since' => $memberSince, | |
358 | ); | |
359 | foreach ($verifyMembershipData as $label => $value) { | |
360 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
361 | preg_quote($value) | |
362 | ); | |
363 | } | |
364 | $this->assertEquals($membershipCreatedId, $membershipRenewedId); | |
365 | } | |
366 | ||
367 | function testUpdateInheritedMembershipOnBehalfOfRenewal() { | |
42daf119 CW |
368 | // Log in as admin |
369 | $this->webtestLogin('admin'); | |
76e86fd8 | 370 | |
42daf119 | 371 | $this->enableComponents('CiviMember'); |
6a488035 | 372 | |
42daf119 CW |
373 | //check for online contribution and profile listings permissions |
374 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); | |
375 | $this->changePermissions($permissions); | |
376 | ||
377 | // Log in as normal user | |
6a488035 TO |
378 | $this->webtestLogin(); |
379 | ||
42daf119 | 380 | $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); |
6a488035 TO |
381 | |
382 | $title = substr(sha1(rand()), 0, 7); | |
383 | $this->type('organization_name', "Organization $title"); | |
384 | $this->type('email_1_email', "$title@org.com"); | |
385 | $this->click('_qf_Contact_upload_view'); | |
386 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
387 | ||
2ac4a694 | 388 | $this->waitForText('crm-notification-container', "Organization $title has been created."); |
6a488035 | 389 | |
071a6d2e | 390 | $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse"); |
6a488035 TO |
391 | |
392 | $this->click('link=Add Membership Type'); | |
393 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
394 | ||
395 | $membershipTypeTitle = "Membership Type $title"; | |
396 | $this->type('name', "Membership Type $title"); | |
76e86fd8 | 397 | |
73072f84 | 398 | $this->select2('member_of_contact_id', $title); |
6a488035 TO |
399 | |
400 | $this->type('minimum_fee', '100'); | |
401 | $this->select( 'financial_type_id', 'value=2' ); | |
402 | $this->type('duration_interval', 1); | |
403 | $this->select('duration_unit', 'label=year'); | |
73072f84 | 404 | $this->select('period_type', 'value=rolling'); |
6a488035 TO |
405 | |
406 | $this->removeSelection('relationship_type_id', 'label=- select -'); | |
407 | $this->addSelection('relationship_type_id', 'label=Employer of'); | |
408 | ||
409 | $this->click('_qf_MembershipType_upload-bottom'); | |
410 | $this->waitForElementPresent('link=Add Membership Type'); | |
2ac4a694 | 411 | $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved."); |
6a488035 | 412 | |
c900afb1 | 413 | $url = $this->getAttribute("xpath=//div[@id='membership_type']//div[@id='option11_wrapper']//table/tbody//tr/td[1][text()='{$membershipTypeTitle}']/../td[12]/span/a[3][text()='Delete']/@href"); |
6a488035 TO |
414 | |
415 | $matches = array(); | |
416 | preg_match('/id=([0-9]+)/', $url, $matches); | |
417 | $membershipTypeId = $matches[1]; | |
418 | ||
419 | // We need a payment processor | |
420 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
421 | ||
6a488035 | 422 | // create contribution page with randomized title and default params |
42daf119 CW |
423 | $hash = substr(sha1(rand()), 0, 7); |
424 | $rand = 2 * rand(2, 50); | |
6a488035 | 425 | $amountSection = FALSE; |
42daf119 CW |
426 | $payLater = FALSE; |
427 | $onBehalf = FALSE; | |
428 | $pledges = FALSE; | |
429 | $recurring = FALSE; | |
430 | $memberships = FALSE; | |
6a488035 | 431 | $memPriceSetId = NULL; |
42daf119 CW |
432 | $friend = FALSE; |
433 | $profilePreId = 1; | |
6a488035 | 434 | $profilePostId = NULL; |
42daf119 CW |
435 | $premiums = FALSE; |
436 | $widget = FALSE; | |
437 | $pcp = FALSE; | |
6a488035 TO |
438 | |
439 | $contributionTitle = "Title $hash"; | |
440 | $pageId = $this->webtestAddContributionPage($hash, | |
441 | $rand, | |
442 | $contributionTitle, | |
443 | array($processorName => 'Dummy'), | |
444 | $amountSection, | |
445 | $payLater, | |
446 | $onBehalf, | |
447 | $pledges, | |
448 | $recurring, | |
449 | $memberships, | |
450 | $memPriceSetId, | |
451 | $friend, | |
452 | $profilePreId, | |
453 | $profilePostId, | |
454 | $premiums, | |
455 | $widget, | |
456 | $pcp, | |
457 | TRUE | |
458 | ); | |
459 | ||
460 | $hash = substr(sha1(rand()), 0, 7); | |
071a6d2e | 461 | $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id=$pageId"); |
6a488035 TO |
462 | |
463 | $this->click('link=Title'); | |
464 | $this->waitForElementPresent('_qf_Settings_cancel-bottom'); | |
465 | $this->click('is_organization'); | |
c900afb1 | 466 | $this->select("xpath=//input[@id='onbehalf_profile_id']/parent::td/div/div/span/select", "value=9"); |
6a488035 TO |
467 | $this->type('for_organization', "On behalf $hash"); |
468 | $this->click('_qf_Settings_next-bottom'); | |
469 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
470 | ||
471 | $this->click('link=Memberships'); | |
472 | $this->waitForElementPresent('_qf_MembershipBlock_cancel-bottom'); | |
473 | $this->click('member_is_active'); | |
474 | $this->type('new_title', "Title - New Membership $hash"); | |
475 | $this->type('renewal_title', "Title - Renewals $hash"); | |
476 | $this->click("membership_type_{$membershipTypeId}"); | |
477 | $this->click('is_required'); | |
478 | $this->click('_qf_MembershipBlock_next-bottom'); | |
479 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
480 | ||
481 | //logout | |
42daf119 | 482 | $this->webtestLogout(); |
6a488035 TO |
483 | |
484 | //get Url for Live Contribution Page | |
071a6d2e | 485 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom'); |
6a488035 | 486 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); |
42daf119 CW |
487 | $firstName = 'Eia' . substr(sha1(rand()), 0, 4); |
488 | $lastName = 'Ande' . substr(sha1(rand()), 0, 4); | |
489 | $name = $firstName . ' ' . $lastName; | |
6a488035 TO |
490 | $organisationName = 'TestOrg' . substr(sha1(rand()), 0, 7); |
491 | ||
492 | $email = $firstName . '@example.com'; | |
493 | $this->type('email-5', $email); | |
494 | $this->click('is_for_organization'); | |
495 | $this->type('onbehalf_organization_name', $organisationName); | |
496 | $this->type('onbehalf_phone-3-1', '2222-222222'); | |
497 | $this->type('onbehalf_email-3', $organisationName . '@example.com'); | |
498 | $this->type('onbehalf_street_address-3', '54A Excelsior Ave. Apt 1C'); | |
499 | $this->type('onbehalf_city-3', 'Driftwood'); | |
500 | $this->type('onbehalf_postal_code-3', '75653'); | |
501 | $this->select('onbehalf_country-3', "value=1228"); | |
502 | $this->select('onbehalf_state_province-3', "value=1061"); | |
503 | ||
504 | $this->type('first_name', $firstName); | |
505 | $this->type('last_name', $lastName); | |
73072f84 | 506 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
507 | |
508 | //Credit Card Info | |
509 | $this->select("credit_card_type", "value=Visa"); | |
510 | $this->select("credit_card_type", "label=Visa"); | |
511 | $this->type("credit_card_number", "4111111111111111"); | |
512 | $this->type("cvv2", "000"); | |
513 | $this->select("credit_card_exp_date[M]", "value=1"); | |
514 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
515 | ||
516 | //Billing Info | |
517 | $this->type("billing_first_name", $firstName . "billing"); | |
518 | $this->type("billing_last_name", $lastName . "billing"); | |
519 | $this->type("billing_street_address-5", "15 Main St."); | |
520 | $this->type(" billing_city-5", "San Jose"); | |
521 | $this->select("billing_country_id-5", "value=1228"); | |
522 | $this->select("billing_state_province_id-5", "value=1004"); | |
523 | $this->type("billing_postal_code-5", "94129"); | |
225a8648 | 524 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
525 | |
526 | $this->click("_qf_Confirm_next-bottom"); | |
527 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
528 | ||
6a488035 | 529 | // Log in using webtestLogin() method |
6a488035 TO |
530 | $this->webtestLogin(); |
531 | ||
532 | //Find member | |
533 | $endDate = date('F jS, Y', strtotime(" +1 year -1 day")); | |
42daf119 | 534 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
535 | |
536 | $this->type("sort_name", "$organisationName"); | |
a1c7d42f CW |
537 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
538 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
539 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
540 | ||
541 | //View Membership Record | |
542 | $verifyMembershipData = array( | |
543 | 'Member' => $organisationName, | |
544 | 'Membership Type' => $membershipTypeTitle, | |
545 | 'Status' => 'New', | |
546 | 'End date' => $endDate, | |
547 | ); | |
548 | ||
549 | foreach ($verifyMembershipData as $label => $value) { | |
550 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
551 | preg_quote($value) | |
552 | ); | |
553 | } | |
554 | ||
42daf119 | 555 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
556 | |
557 | $this->type("sort_name", "$lastName, $firstName"); | |
a1c7d42f CW |
558 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
559 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
560 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
561 | ||
562 | //View Membership Record | |
563 | $verifyMembershipData = array( | |
564 | 'Member' => $name, | |
565 | 'Membership Type' => $membershipTypeTitle, | |
566 | 'Status' => 'New', | |
567 | 'End date' => $endDate, | |
568 | ); | |
569 | ||
570 | foreach ($verifyMembershipData as $label => $value) { | |
571 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
572 | preg_quote($value) | |
573 | ); | |
574 | } | |
575 | ||
576 | //logout | |
42daf119 | 577 | $this->webtestLogout(); |
6a488035 | 578 | |
b45c587e | 579 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); |
6a488035 TO |
580 | |
581 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); | |
582 | $this->type("email-5", $email); | |
583 | $this->click('is_for_organization'); | |
584 | $this->type('onbehalf_organization_name', $organisationName); | |
585 | $this->type('onbehalf_phone-3-1', '2222-222222'); | |
586 | $this->type('onbehalf_email-3', $organisationName . '@example.com'); | |
587 | $this->type('onbehalf_street_address-3', '22A Excelsior Ave. Unit 1h'); | |
588 | $this->type('onbehalf_city-3', 'Driftwood'); | |
589 | $this->type('onbehalf_postal_code-3', '75653'); | |
590 | $this->select('onbehalf_country-3', "value=1228"); | |
591 | $this->select('onbehalf_state_province-3', "value=1061"); | |
592 | ||
593 | $this->type('first_name', $firstName); | |
594 | $this->type('last_name', $lastName); | |
73072f84 | 595 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
596 | |
597 | //Credit Card Info | |
598 | $this->select("credit_card_type", "value=Visa"); | |
599 | $this->select("credit_card_type", "label=Visa"); | |
600 | $this->type("credit_card_number", "4111111111111111"); | |
601 | $this->type("cvv2", "000"); | |
602 | $this->select("credit_card_exp_date[M]", "value=1"); | |
603 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
604 | ||
605 | //Billing Info | |
606 | $this->type("billing_first_name", $firstName . "billing"); | |
607 | $this->type("billing_last_name", $lastName . "billing"); | |
608 | $this->type("billing_street_address-5", "15 Main St."); | |
609 | $this->type(" billing_city-5", "San Jose"); | |
610 | $this->select("billing_country_id-5", "value=1228"); | |
611 | $this->select("billing_state_province_id-5", "value=1004"); | |
612 | $this->type("billing_postal_code-5", "94129"); | |
613 | ||
225a8648 | 614 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
615 | |
616 | $this->click("_qf_Confirm_next-bottom"); | |
617 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
618 | ||
619 | // Log in using webtestLogin() method | |
6a488035 TO |
620 | $this->webtestLogin(); |
621 | ||
622 | //Find member | |
623 | $endDate = date('F jS, Y', strtotime(" +2 year -1 day")); | |
42daf119 | 624 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
625 | |
626 | $this->type("sort_name", "$organisationName"); | |
a1c7d42f CW |
627 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
628 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
629 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
630 | ||
631 | //View Membership Record | |
632 | $verifyMembershipData = array( | |
633 | 'Member' => $organisationName, | |
634 | 'Membership Type' => $membershipTypeTitle, | |
635 | 'End date' => $endDate, | |
636 | ); | |
637 | ||
638 | foreach ($verifyMembershipData as $label => $value) { | |
639 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
640 | preg_quote($value) | |
641 | ); | |
642 | } | |
643 | ||
42daf119 | 644 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
645 | |
646 | $this->type("sort_name", "$lastName, $firstName"); | |
a1c7d42f CW |
647 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
648 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
649 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
650 | ||
651 | //View Membership Record | |
652 | $verifyMembershipData = array( | |
653 | 'Member' => $name, | |
654 | 'Membership Type' => $membershipTypeTitle, | |
655 | 'End date' => $endDate, | |
656 | ); | |
657 | ||
658 | foreach ($verifyMembershipData as $label => $value) { | |
659 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
660 | preg_quote($value) | |
661 | ); | |
662 | } | |
663 | } | |
664 | } | |
665 |