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