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 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
b45c587e CW |
34 | /** |
35 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
36 | */ | |
6a488035 TO |
37 | function testOnlineMembershipRenew() { |
38 | // a random 7-char string and an even number to make this pass unique | |
39 | $hash = substr(sha1(rand()), 0, 7); | |
40 | $rand = 2 * rand(2, 50); | |
41 | ||
6a488035 TO |
42 | // Log in using webtestLogin() method |
43 | $this->webtestLogin(); | |
44 | ||
45 | // We need a payment processor | |
46 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
47 | $this->webtestAddPaymentProcessor($processorName); | |
48 | ||
42daf119 | 49 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next"); |
6a488035 TO |
50 | // this contribution page for membership signup |
51 | // select newly created processor | |
52 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
2ac4a694 | 53 | $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName); |
6a488035 TO |
54 | $this->check($xpath); |
55 | ||
56 | // save | |
57 | $this->waitForElementPresent("_qf_Amount_next"); | |
b45c587e | 58 | $this->clickLink('_qf_Amount_next'); |
6a488035 TO |
59 | |
60 | // go to Membership block | |
61 | $this->click('css=#tab_membership a'); | |
62 | $this->waitForElementPresent("member_is_active"); | |
63 | $this->check("member_is_active"); | |
76e86fd8 CW |
64 | |
65 | $this->waitForElementPresent("new_title"); | |
66 | ||
6a488035 | 67 | if ($this->isElementPresent("member_price_set_id")) { |
76e86fd8 CW |
68 | $this->waitForElementPresent("member_price_set_id"); |
69 | ||
6a488035 TO |
70 | $this->select("member_price_set_id", "label=- none -"); |
71 | } | |
76e86fd8 | 72 | |
6a488035 TO |
73 | $this->waitForElementPresent("membership_type-block"); |
74 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
75 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
76 | $this->click("_qf_MembershipBlock_next-bottom"); | |
77 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
76e86fd8 | 78 | |
6a488035 TO |
79 | // go to Profiles |
80 | $this->click('css=#tab_custom a'); | |
81 | ||
82 | // fill in Profiles | |
83 | $this->waitForElementPresent('custom_pre_id'); | |
73072f84 | 84 | $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1'); |
6a488035 TO |
85 | |
86 | // save | |
87 | $this->click('_qf_Custom_upload_done'); | |
88 | $this->waitForPageToLoad(); | |
89 | ||
90 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
42daf119 CW |
91 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
92 | $email = $firstName . "@example.com"; | |
6a488035 TO |
93 | |
94 | //logout | |
42daf119 | 95 | $this->webtestLogout(); |
6a488035 TO |
96 | |
97 | //Go to online membership signup page | |
42daf119 | 98 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
76e86fd8 | 99 | |
6a488035 TO |
100 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
101 | ||
102 | //Type first name and last name and email | |
103 | $this->type("first_name", $firstName); | |
104 | $this->type("last_name", $lastName); | |
105 | $this->type("email-5", $email); | |
73072f84 | 106 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
107 | |
108 | //Credit Card Info | |
109 | $this->select("credit_card_type", "value=Visa"); | |
110 | $this->select("credit_card_type", "label=Visa"); | |
111 | $this->type("credit_card_number", "4111111111111111"); | |
112 | $this->type("cvv2", "000"); | |
113 | $this->select("credit_card_exp_date[M]", "value=1"); | |
114 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
115 | ||
116 | //Billing Info | |
117 | $this->type("billing_first_name", $firstName . "billing"); | |
118 | $this->type("billing_last_name", $lastName . "billing"); | |
119 | $this->type("billing_street_address-5", "15 Main St."); | |
120 | $this->type(" billing_city-5", "San Jose"); | |
121 | $this->select("billing_country_id-5", "value=1228"); | |
122 | $this->select("billing_state_province_id-5", "value=1004"); | |
123 | $this->type("billing_postal_code-5", "94129"); | |
124 | ||
225a8648 | 125 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
126 | |
127 | $this->click("_qf_Confirm_next-bottom"); | |
128 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
129 | ||
130 | // Log in using webtestLogin() method | |
6a488035 TO |
131 | $this->webtestLogin(); |
132 | //Find Member | |
42daf119 | 133 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
134 | |
135 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
136 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
137 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
138 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
139 | ||
140 | //View Membership Record | |
141 | $verifyMembershipData = array( | |
142 | 'Member' => $firstName . ' ' . $lastName, | |
143 | 'Membership Type' => 'Student', | |
144 | 'Status' => 'New', | |
145 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
146 | ); | |
147 | foreach ($verifyMembershipData as $label => $value) { | |
148 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
149 | preg_quote($value) | |
150 | ); | |
151 | } | |
152 | ||
153 | //logout | |
42daf119 | 154 | $this->webtestLogout(); |
6a488035 | 155 | |
42daf119 | 156 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
157 | |
158 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); | |
159 | ||
160 | //Type first name and last name and email | |
161 | $this->type("first_name", $firstName); | |
162 | $this->type("last_name", $lastName); | |
163 | $this->type("email-5", $email); | |
73072f84 | 164 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
165 | |
166 | //Credit Card Info | |
167 | $this->select("credit_card_type", "value=Visa"); | |
168 | $this->select("credit_card_type", "label=Visa"); | |
169 | $this->type("credit_card_number", "4111111111111111"); | |
170 | $this->type("cvv2", "000"); | |
171 | $this->select("credit_card_exp_date[M]", "value=1"); | |
172 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
173 | ||
174 | //Billing Info | |
175 | $this->type("billing_first_name", $firstName . "billing"); | |
176 | $this->type("billing_last_name", $lastName . "billing"); | |
177 | $this->type("billing_street_address-5", "15 Main St."); | |
178 | $this->type(" billing_city-5", "San Jose"); | |
179 | $this->select("billing_country_id-5", "value=1228"); | |
180 | $this->select("billing_state_province_id-5", "value=1004"); | |
181 | $this->type("billing_postal_code-5", "94129"); | |
182 | ||
225a8648 | 183 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
184 | $this->click("_qf_Confirm_next-bottom"); |
185 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
186 | ||
6a488035 TO |
187 | $this->webtestLogin(); |
188 | //Find Member | |
42daf119 | 189 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
190 | |
191 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
192 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
193 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
194 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
195 | ||
196 | //View Membership Record | |
197 | $verifyMembershipData = array( | |
198 | 'Member' => $firstName . ' ' . $lastName, | |
199 | 'Membership Type' => 'Student', | |
200 | 'Status' => 'New', | |
201 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
202 | ); | |
203 | foreach ($verifyMembershipData as $label => $value) { | |
204 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
205 | preg_quote($value) | |
206 | ); | |
207 | } | |
208 | } | |
209 | ||
b45c587e CW |
210 | /** |
211 | * FIXME: This test tries to update a contribution page (id=2) that may not exist :( | |
212 | */ | |
6a488035 TO |
213 | function testOnlineMembershipRenewChangeType() { |
214 | // a random 7-char string and an even number to make this pass unique | |
215 | $hash = substr(sha1(rand()), 0, 7); | |
216 | $rand = 2 * rand(2, 50); | |
217 | ||
6a488035 TO |
218 | // Log in using webtestLogin() method |
219 | $this->webtestLogin(); | |
220 | ||
221 | // We need a payment processor | |
222 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
223 | $this->webtestAddPaymentProcessor($processorName); | |
224 | ||
42daf119 | 225 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next'); |
6a488035 TO |
226 | |
227 | //this contribution page for membership signup | |
228 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
2ac4a694 | 229 | $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName); |
6a488035 TO |
230 | $this->check($xpath); |
231 | ||
232 | // save | |
233 | $this->waitForElementPresent('_qf_Amount_next'); | |
234 | $this->click('_qf_Amount_next'); | |
235 | $this->waitForPageToLoad(); | |
236 | ||
237 | // go to Membership block | |
238 | $this->click('css=#tab_membership a'); | |
239 | $this->waitForElementPresent("member_is_active"); | |
240 | $this->check("member_is_active"); | |
76e86fd8 | 241 | |
6a488035 TO |
242 | $this->waitForElementPresent("new_title"); |
243 | if ($this->isElementPresent("member_price_set_id")) { | |
76e86fd8 CW |
244 | $this->waitForElementPresent("member_price_set_id"); |
245 | ||
6a488035 TO |
246 | $this->select("member_price_set_id", "label=- none -"); |
247 | } | |
76e86fd8 | 248 | |
6a488035 TO |
249 | $this->waitForElementPresent("membership_type-block"); |
250 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]"); | |
251 | $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]"); | |
252 | $this->click("_qf_MembershipBlock_next-bottom"); | |
253 | $this->waitForTextPresent("'MembershipBlock' information has been saved"); | |
76e86fd8 | 254 | |
6a488035 TO |
255 | // go to Profiles |
256 | $this->click('css=#tab_custom a'); | |
257 | ||
258 | // fill in Profiles | |
259 | $this->waitForElementPresent('custom_pre_id'); | |
73072f84 | 260 | $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1'); |
6a488035 TO |
261 | |
262 | // save | |
263 | $this->click('_qf_Custom_upload_done'); | |
264 | $this->waitForPageToLoad(); | |
265 | ||
266 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
267 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
268 | ||
269 | //Go to online membership signup page | |
42daf119 | 270 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
271 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'General')]"); |
272 | //Type first name and last name | |
273 | $this->type("first_name", $firstName); | |
274 | $this->type("last_name", $lastName); | |
275 | ||
73072f84 | 276 | $this->select("state_province-1", "value=1001"); |
6a488035 TO |
277 | //Credit Card Info |
278 | $this->select("credit_card_type", "value=Visa"); | |
279 | $this->select("credit_card_type", "label=Visa"); | |
280 | $this->type("credit_card_number", "4111111111111111"); | |
281 | $this->type("cvv2", "000"); | |
282 | $this->select("credit_card_exp_date[M]", "value=1"); | |
283 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
284 | ||
285 | //Billing Info | |
286 | $this->type("billing_first_name", $firstName . "billing"); | |
287 | $this->type("billing_last_name", $lastName . "billing"); | |
288 | $this->type("billing_street_address-5", "15 Main St."); | |
289 | $this->type(" billing_city-5", "San Jose"); | |
290 | $this->select("billing_country_id-5", "value=1228"); | |
291 | $this->select("billing_state_province_id-5", "value=1004"); | |
292 | $this->type("billing_postal_code-5", "94129"); | |
293 | ||
225a8648 | 294 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
295 | |
296 | $this->click("_qf_Confirm_next-bottom"); | |
297 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
298 | ||
299 | //Find Member | |
42daf119 | 300 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
301 | |
302 | $this->type("sort_name", "$firstName $lastName"); | |
a1c7d42f CW |
303 | $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child'); |
304 | $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
305 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
306 | ||
a471a3b6 | 307 | $membershipCreatedId = $this->urlArg('id'); |
6a488035 TO |
308 | |
309 | $memberSince = date('F jS, Y'); | |
310 | ||
311 | //View Membership Record | |
312 | $verifyMembershipData = array( | |
313 | 'Member' => $firstName . ' ' . $lastName, | |
314 | 'Membership Type' => 'General', | |
315 | 'Status' => 'New', | |
316 | 'Source' => 'Online Contribution: Member Signup and Renewal', | |
317 | ); | |
318 | foreach ($verifyMembershipData as $label => $value) { | |
319 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
320 | preg_quote($value) | |
321 | ); | |
322 | } | |
42daf119 | 323 | $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); |
6a488035 TO |
324 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); |
325 | ||
326 | //Credit Card Info | |
327 | $this->select("credit_card_type", "value=Visa"); | |
328 | $this->select("credit_card_type", "label=Visa"); | |
329 | $this->type("credit_card_number", "4111111111111111"); | |
330 | $this->type("cvv2", "000"); | |
331 | $this->select("credit_card_exp_date[M]", "value=1"); | |
332 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
225a8648 | 333 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
334 | $this->click("_qf_Confirm_next-bottom"); |
335 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
336 | ||
337 | //Find Member | |
42daf119 | 338 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
339 | |
340 | $this->type("sort_name", "$firstName $lastName"); | |
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 | ||
363 | 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'); | |
397 | $this->select( 'financial_type_id', 'value=2' ); | |
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 TO |
408 | |
409 | $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"); | |
410 | ||
411 | $matches = array(); | |
412 | preg_match('/id=([0-9]+)/', $url, $matches); | |
413 | $membershipTypeId = $matches[1]; | |
414 | ||
415 | // We need a payment processor | |
416 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
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'); | |
462 | $this->select('onbehalf_profile_id', "value=9"); | |
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'); |
6a488035 | 482 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][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 TO |
576 | |
577 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); | |
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 | } | |
660 | } | |
661 |