Refactor ad-hoc url parsing to use the new urlArg() method
[civicrm-core.git] / tests / phpunit / WebTest / Member / OnlineMembershipRenewTest.php
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 /**
35 * FIXME: This test tries to update a contribution page (id=2) that may not exist :(
36 */
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
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
49 $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next");
50 // this contribution page for membership signup
51 // select newly created processor
52 $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
53 $this->assertTrue($this->isTextPresent($processorName));
54 $this->check($xpath);
55
56 // save
57 $this->waitForElementPresent("_qf_Amount_next");
58 $this->clickLink('_qf_Amount_next');
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");
64
65 $this->waitForElementPresent("new_title");
66
67 if ($this->isElementPresent("member_price_set_id")) {
68 $this->waitForElementPresent("member_price_set_id");
69
70 $this->select("member_price_set_id", "label=- none -");
71 }
72
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");
78
79 // go to Profiles
80 $this->click('css=#tab_custom a');
81
82 // fill in Profiles
83 $this->waitForElementPresent('custom_pre_id');
84 $this->select('custom_pre_id', 'value=1');
85
86 // save
87 $this->click('_qf_Custom_upload_done');
88 $this->waitForPageToLoad();
89
90 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
91 $lastName = 'An' . substr(sha1(rand()), 0, 7);
92 $email = $firstName . "@example.com";
93
94 //logout
95 $this->webtestLogout();
96
97 //Go to online membership signup page
98 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
99
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);
106
107 //Credit Card Info
108 $this->select("credit_card_type", "value=Visa");
109 $this->select("credit_card_type", "label=Visa");
110 $this->type("credit_card_number", "4111111111111111");
111 $this->type("cvv2", "000");
112 $this->select("credit_card_exp_date[M]", "value=1");
113 $this->select("credit_card_exp_date[Y]", "value=2020");
114
115 //Billing Info
116 $this->type("billing_first_name", $firstName . "billing");
117 $this->type("billing_last_name", $lastName . "billing");
118 $this->type("billing_street_address-5", "15 Main St.");
119 $this->type(" billing_city-5", "San Jose");
120 $this->select("billing_country_id-5", "value=1228");
121 $this->select("billing_state_province_id-5", "value=1004");
122 $this->type("billing_postal_code-5", "94129");
123
124 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
125
126 $this->click("_qf_Confirm_next-bottom");
127 $this->waitForPageToLoad($this->getTimeoutMsec());
128
129 // Log in using webtestLogin() method
130 $this->webtestLogin();
131 //Find Member
132 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
133
134 $this->type("sort_name", "$firstName $lastName");
135 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
136 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
137 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
138
139 //View Membership Record
140 $verifyMembershipData = array(
141 'Member' => $firstName . ' ' . $lastName,
142 'Membership Type' => 'Student',
143 'Status' => 'New',
144 'Source' => 'Online Contribution: Member Signup and Renewal',
145 );
146 foreach ($verifyMembershipData as $label => $value) {
147 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
148 preg_quote($value)
149 );
150 }
151
152 //logout
153 $this->webtestLogout();
154
155 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
156
157 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
158
159 //Type first name and last name and email
160 $this->type("first_name", $firstName);
161 $this->type("last_name", $lastName);
162 $this->type("email-5", $email);
163
164 //Credit Card Info
165 $this->select("credit_card_type", "value=Visa");
166 $this->select("credit_card_type", "label=Visa");
167 $this->type("credit_card_number", "4111111111111111");
168 $this->type("cvv2", "000");
169 $this->select("credit_card_exp_date[M]", "value=1");
170 $this->select("credit_card_exp_date[Y]", "value=2020");
171
172 //Billing Info
173 $this->type("billing_first_name", $firstName . "billing");
174 $this->type("billing_last_name", $lastName . "billing");
175 $this->type("billing_street_address-5", "15 Main St.");
176 $this->type(" billing_city-5", "San Jose");
177 $this->select("billing_country_id-5", "value=1228");
178 $this->select("billing_state_province_id-5", "value=1004");
179 $this->type("billing_postal_code-5", "94129");
180
181 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
182 $this->click("_qf_Confirm_next-bottom");
183 $this->waitForPageToLoad($this->getTimeoutMsec());
184
185 $this->webtestLogin();
186 //Find Member
187 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
188
189 $this->type("sort_name", "$firstName $lastName");
190 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
191 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
192 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
193
194 //View Membership Record
195 $verifyMembershipData = array(
196 'Member' => $firstName . ' ' . $lastName,
197 'Membership Type' => 'Student',
198 'Status' => 'New',
199 'Source' => 'Online Contribution: Member Signup and Renewal',
200 );
201 foreach ($verifyMembershipData as $label => $value) {
202 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
203 preg_quote($value)
204 );
205 }
206 }
207
208 /**
209 * FIXME: This test tries to update a contribution page (id=2) that may not exist :(
210 */
211 function testOnlineMembershipRenewChangeType() {
212 // a random 7-char string and an even number to make this pass unique
213 $hash = substr(sha1(rand()), 0, 7);
214 $rand = 2 * rand(2, 50);
215
216 // Log in using webtestLogin() method
217 $this->webtestLogin();
218
219 // We need a payment processor
220 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
221 $this->webtestAddPaymentProcessor($processorName);
222
223 $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next');
224
225 //this contribution page for membership signup
226 $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
227 $this->assertTrue($this->isTextPresent($processorName));
228 $this->check($xpath);
229
230 // save
231 $this->waitForElementPresent('_qf_Amount_next');
232 $this->click('_qf_Amount_next');
233 $this->waitForPageToLoad();
234
235 // go to Membership block
236 $this->click('css=#tab_membership a');
237 $this->waitForElementPresent("member_is_active");
238 $this->check("member_is_active");
239
240 $this->waitForElementPresent("new_title");
241 if ($this->isElementPresent("member_price_set_id")) {
242 $this->waitForElementPresent("member_price_set_id");
243
244 $this->select("member_price_set_id", "label=- none -");
245 }
246
247 $this->waitForElementPresent("membership_type-block");
248 $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]");
249 $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]");
250 $this->click("_qf_MembershipBlock_next-bottom");
251 $this->waitForTextPresent("'MembershipBlock' information has been saved");
252
253 // go to Profiles
254 $this->click('css=#tab_custom a');
255
256 // fill in Profiles
257 $this->waitForElementPresent('custom_pre_id');
258 $this->select('custom_pre_id', 'value=1');
259
260 // save
261 $this->click('_qf_Custom_upload_done');
262 $this->waitForPageToLoad();
263
264 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
265 $lastName = 'An' . substr(sha1(rand()), 0, 7);
266
267 //Go to online membership signup page
268 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
269 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'General')]");
270 //Type first name and last name
271 $this->type("first_name", $firstName);
272 $this->type("last_name", $lastName);
273
274 //Credit Card Info
275 $this->select("credit_card_type", "value=Visa");
276 $this->select("credit_card_type", "label=Visa");
277 $this->type("credit_card_number", "4111111111111111");
278 $this->type("cvv2", "000");
279 $this->select("credit_card_exp_date[M]", "value=1");
280 $this->select("credit_card_exp_date[Y]", "value=2020");
281
282 //Billing Info
283 $this->type("billing_first_name", $firstName . "billing");
284 $this->type("billing_last_name", $lastName . "billing");
285 $this->type("billing_street_address-5", "15 Main St.");
286 $this->type(" billing_city-5", "San Jose");
287 $this->select("billing_country_id-5", "value=1228");
288 $this->select("billing_state_province_id-5", "value=1004");
289 $this->type("billing_postal_code-5", "94129");
290
291 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
292
293 $this->click("_qf_Confirm_next-bottom");
294 $this->waitForPageToLoad($this->getTimeoutMsec());
295
296 //Find Member
297 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
298
299 $this->type("sort_name", "$firstName $lastName");
300 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
301 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
302 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
303
304 $membershipCreatedId = $this->urlArg('id');
305
306 $memberSince = date('F jS, Y');
307
308 //View Membership Record
309 $verifyMembershipData = array(
310 'Member' => $firstName . ' ' . $lastName,
311 'Membership Type' => 'General',
312 'Status' => 'New',
313 'Source' => 'Online Contribution: Member Signup and Renewal',
314 );
315 foreach ($verifyMembershipData as $label => $value) {
316 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
317 preg_quote($value)
318 );
319 }
320 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
321 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
322
323 //Credit Card Info
324 $this->select("credit_card_type", "value=Visa");
325 $this->select("credit_card_type", "label=Visa");
326 $this->type("credit_card_number", "4111111111111111");
327 $this->type("cvv2", "000");
328 $this->select("credit_card_exp_date[M]", "value=1");
329 $this->select("credit_card_exp_date[Y]", "value=2020");
330 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
331 $this->click("_qf_Confirm_next-bottom");
332 $this->waitForPageToLoad($this->getTimeoutMsec());
333
334 //Find Member
335 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
336
337 $this->type("sort_name", "$firstName $lastName");
338 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
339 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
340 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
341
342 $membershipRenewedId = $this->urlArg('id');
343
344 //View Membership Record
345 $verifyMembershipData = array(
346 'Member' => $firstName . ' ' . $lastName,
347 'Membership Type' => 'Student',
348 'Status' => 'New',
349 'Source' => 'Online Contribution: Member Signup and Renewal',
350 'Member Since' => $memberSince,
351 );
352 foreach ($verifyMembershipData as $label => $value) {
353 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
354 preg_quote($value)
355 );
356 }
357 $this->assertEquals($membershipCreatedId, $membershipRenewedId);
358 }
359
360 function testUpdateInheritedMembershipOnBehalfOfRenewal() {
361 // Log in as admin
362 $this->webtestLogin('admin');
363
364 $this->enableComponents('CiviMember');
365
366 //check for online contribution and profile listings permissions
367 $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
368 $this->changePermissions($permissions);
369
370 // Log in as normal user
371 $this->webtestLogin();
372
373 $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
374
375 $title = substr(sha1(rand()), 0, 7);
376 $this->type('organization_name', "Organization $title");
377 $this->type('email_1_email', "$title@org.com");
378 $this->click('_qf_Contact_upload_view');
379 $this->waitForPageToLoad($this->getTimeoutMsec());
380
381 $this->assertTrue($this->isTextPresent("Organization $title has been created."));
382
383 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
384
385 $this->click('link=Add Membership Type');
386 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
387
388 $membershipTypeTitle = "Membership Type $title";
389 $this->type('name', "Membership Type $title");
390
391 $this->type('member_of_contact', $title);
392 $this->click('member_of_contact');
393 $this->waitForElementPresent("css=div.ac_results-inner li");
394 $this->click("css=div.ac_results-inner li");
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');
400 $this->select('period_type', 'label=rolling');
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');
407 $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved."));
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
418 // create contribution page with randomized title and default params
419 $hash = substr(sha1(rand()), 0, 7);
420 $rand = 2 * rand(2, 50);
421 $amountSection = FALSE;
422 $payLater = FALSE;
423 $onBehalf = FALSE;
424 $pledges = FALSE;
425 $recurring = FALSE;
426 $memberships = FALSE;
427 $memPriceSetId = NULL;
428 $friend = FALSE;
429 $profilePreId = 1;
430 $profilePostId = NULL;
431 $premiums = FALSE;
432 $widget = FALSE;
433 $pcp = FALSE;
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);
457 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id=$pageId");
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
478 $this->webtestLogout();
479
480 //get Url for Live Contribution Page
481 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
482 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]");
483 $firstName = 'Eia' . substr(sha1(rand()), 0, 4);
484 $lastName = 'Ande' . substr(sha1(rand()), 0, 4);
485 $name = $firstName . ' ' . $lastName;
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);
502
503 //Credit Card Info
504 $this->select("credit_card_type", "value=Visa");
505 $this->select("credit_card_type", "label=Visa");
506 $this->type("credit_card_number", "4111111111111111");
507 $this->type("cvv2", "000");
508 $this->select("credit_card_exp_date[M]", "value=1");
509 $this->select("credit_card_exp_date[Y]", "value=2020");
510
511 //Billing Info
512 $this->type("billing_first_name", $firstName . "billing");
513 $this->type("billing_last_name", $lastName . "billing");
514 $this->type("billing_street_address-5", "15 Main St.");
515 $this->type(" billing_city-5", "San Jose");
516 $this->select("billing_country_id-5", "value=1228");
517 $this->select("billing_state_province_id-5", "value=1004");
518 $this->type("billing_postal_code-5", "94129");
519 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
520
521 $this->click("_qf_Confirm_next-bottom");
522 $this->waitForPageToLoad($this->getTimeoutMsec());
523
524 // Log in using webtestLogin() method
525 $this->webtestLogin();
526
527 //Find member
528 $endDate = date('F jS, Y', strtotime(" +1 year -1 day"));
529 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
530
531 $this->type("sort_name", "$organisationName");
532 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
533 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
534 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
535
536 //View Membership Record
537 $verifyMembershipData = array(
538 'Member' => $organisationName,
539 'Membership Type' => $membershipTypeTitle,
540 'Status' => 'New',
541 'End date' => $endDate,
542 );
543
544 foreach ($verifyMembershipData as $label => $value) {
545 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
546 preg_quote($value)
547 );
548 }
549
550 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
551
552 $this->type("sort_name", "$lastName, $firstName");
553 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
554 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
555 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
556
557 //View Membership Record
558 $verifyMembershipData = array(
559 'Member' => $name,
560 'Membership Type' => $membershipTypeTitle,
561 'Status' => 'New',
562 'End date' => $endDate,
563 );
564
565 foreach ($verifyMembershipData as $label => $value) {
566 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
567 preg_quote($value)
568 );
569 }
570
571 //logout
572 $this->webtestLogout();
573
574 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
575
576 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]");
577 $this->type("email-5", $email);
578 $this->click('is_for_organization');
579 $this->type('onbehalf_organization_name', $organisationName);
580 $this->type('onbehalf_phone-3-1', '2222-222222');
581 $this->type('onbehalf_email-3', $organisationName . '@example.com');
582 $this->type('onbehalf_street_address-3', '22A Excelsior Ave. Unit 1h');
583 $this->type('onbehalf_city-3', 'Driftwood');
584 $this->type('onbehalf_postal_code-3', '75653');
585 $this->select('onbehalf_country-3', "value=1228");
586 $this->select('onbehalf_state_province-3', "value=1061");
587
588 $this->type('first_name', $firstName);
589 $this->type('last_name', $lastName);
590
591 //Credit Card Info
592 $this->select("credit_card_type", "value=Visa");
593 $this->select("credit_card_type", "label=Visa");
594 $this->type("credit_card_number", "4111111111111111");
595 $this->type("cvv2", "000");
596 $this->select("credit_card_exp_date[M]", "value=1");
597 $this->select("credit_card_exp_date[Y]", "value=2020");
598
599 //Billing Info
600 $this->type("billing_first_name", $firstName . "billing");
601 $this->type("billing_last_name", $lastName . "billing");
602 $this->type("billing_street_address-5", "15 Main St.");
603 $this->type(" billing_city-5", "San Jose");
604 $this->select("billing_country_id-5", "value=1228");
605 $this->select("billing_state_province_id-5", "value=1004");
606 $this->type("billing_postal_code-5", "94129");
607
608 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
609
610 $this->click("_qf_Confirm_next-bottom");
611 $this->waitForPageToLoad($this->getTimeoutMsec());
612
613 // Log in using webtestLogin() method
614 $this->webtestLogin();
615
616 //Find member
617 $endDate = date('F jS, Y', strtotime(" +2 year -1 day"));
618 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
619
620 $this->type("sort_name", "$organisationName");
621 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
622 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
623 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
624
625 //View Membership Record
626 $verifyMembershipData = array(
627 'Member' => $organisationName,
628 'Membership Type' => $membershipTypeTitle,
629 'End date' => $endDate,
630 );
631
632 foreach ($verifyMembershipData as $label => $value) {
633 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
634 preg_quote($value)
635 );
636 }
637
638 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
639
640 $this->type("sort_name", "$lastName, $firstName");
641 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item-first');
642 $this->click('css=#memberSearch table tbody tr td span a.action-item-first');
643 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
644
645 //View Membership Record
646 $verifyMembershipData = array(
647 'Member' => $name,
648 'Membership Type' => $membershipTypeTitle,
649 'End date' => $endDate,
650 );
651
652 foreach ($verifyMembershipData as $label => $value) {
653 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
654 preg_quote($value)
655 );
656 }
657 }
658 }
659