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