Merge pull request #4733 from rohankatkar/Tests
[civicrm-core.git] / tests / phpunit / WebTest / Member / OnlineMembershipRenewTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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
29 /**
30 * Class WebTest_Member_OnlineMembershipRenewTest
31 */
32 class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 /**
39 * FIXME: This test tries to update a contribution page (id=2) that may not exist :(
40 */
41 function testOnlineMembershipRenew() {
42 // a random 7-char string and an even number to make this pass unique
43 $hash = substr(sha1(rand()), 0, 7);
44 $rand = 2 * rand(2, 50);
45
46 // Log in using webtestLogin() method
47 $this->webtestLogin();
48
49 // Use default payment processor
50 $processorName = 'Test Processor';
51 $this->webtestAddPaymentProcessor($processorName);
52
53 $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next");
54 // this contribution page for membership signup
55 // select newly created processor
56 $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
57 $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName);
58 $this->check($xpath);
59
60 // save
61 $this->waitForElementPresent("_qf_Amount_next");
62 $this->clickLink('_qf_Amount_next');
63
64 // go to Membership block
65 $this->click('css=#tab_membership a');
66 $this->waitForElementPresent("member_is_active");
67 $this->check("member_is_active");
68
69 $this->waitForElementPresent("new_title");
70
71 if ($this->isElementPresent("member_price_set_id")) {
72 $this->waitForElementPresent("member_price_set_id");
73
74 $this->select("member_price_set_id", "label=- none -");
75 }
76
77 $this->waitForElementPresent("membership_type-block");
78 $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]");
79 $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]");
80 $this->click("_qf_MembershipBlock_next-bottom");
81 $this->waitForTextPresent("'MembershipBlock' information has been saved");
82
83 // go to Profiles
84 $this->click('css=#tab_custom a');
85
86 // fill in Profiles
87 $this->waitForElementPresent('custom_pre_id');
88 $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1');
89
90 // save
91 $this->click('_qf_Custom_upload_done');
92 $this->waitForPageToLoad();
93
94 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
95 $lastName = 'An' . substr(sha1(rand()), 0, 7);
96 $email = $firstName . "@example.com";
97
98 //logout
99 $this->webtestLogout();
100
101 //Go to online membership signup page
102 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
103
104 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
105
106 //Type first name and last name and email
107 $this->type("first_name", $firstName);
108 $this->type("last_name", $lastName);
109 $this->type("email-5", $email);
110 $this->select("state_province-1", "value=1001");
111
112 //Credit Card Info
113 $this->select("credit_card_type", "value=Visa");
114 $this->select("credit_card_type", "label=Visa");
115 $this->type("credit_card_number", "4111111111111111");
116 $this->type("cvv2", "000");
117 $this->select("credit_card_exp_date[M]", "value=1");
118 $this->select("credit_card_exp_date[Y]", "value=2020");
119
120 //Billing Info
121 $this->type("billing_first_name", $firstName . "billing");
122 $this->type("billing_last_name", $lastName . "billing");
123 $this->type("billing_street_address-5", "15 Main St.");
124 $this->type(" billing_city-5", "San Jose");
125 $this->select("billing_country_id-5", "value=1228");
126 $this->select("billing_state_province_id-5", "value=1004");
127 $this->type("billing_postal_code-5", "94129");
128
129 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
130
131 $this->click("_qf_Confirm_next-bottom");
132
133 // Log in using webtestLogin() method
134 $this->webtestLogin();
135 //Find Member
136 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
137
138 $this->type("sort_name", "$lastName $firstName");
139 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
140 $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
141 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
142
143 //View Membership Record
144 $verifyMembershipData = array(
145 'Member' => $firstName . ' ' . $lastName,
146 'Membership Type' => 'Student',
147 'Status' => 'New',
148 'Source' => 'Online Contribution: Member Signup and Renewal',
149 );
150 foreach ($verifyMembershipData as $label => $value) {
151 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
152 preg_quote($value)
153 );
154 }
155
156 //logout
157 $this->webtestLogout();
158
159 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
160
161 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
162
163 //Type first name and last name and email
164 $this->type("first_name", $firstName);
165 $this->type("last_name", $lastName);
166 $this->type("email-5", $email);
167 $this->select("state_province-1", "value=1001");
168
169 //Credit Card Info
170 $this->select("credit_card_type", "value=Visa");
171 $this->select("credit_card_type", "label=Visa");
172 $this->type("credit_card_number", "4111111111111111");
173 $this->type("cvv2", "000");
174 $this->select("credit_card_exp_date[M]", "value=1");
175 $this->select("credit_card_exp_date[Y]", "value=2020");
176
177 //Billing Info
178 $this->type("billing_first_name", $firstName . "billing");
179 $this->type("billing_last_name", $lastName . "billing");
180 $this->type("billing_street_address-5", "15 Main St.");
181 $this->type(" billing_city-5", "San Jose");
182 $this->select("billing_country_id-5", "value=1228");
183 $this->select("billing_state_province_id-5", "value=1004");
184 $this->type("billing_postal_code-5", "94129");
185
186 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
187 $this->click("_qf_Confirm_next-bottom");
188
189 $this->webtestLogin();
190 //Find Member
191 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
192
193 $this->type("sort_name", "$lastName $firstName");
194 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
195 $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
196 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
197
198 //View Membership Record
199 $verifyMembershipData = array(
200 'Member' => $firstName . ' ' . $lastName,
201 'Membership Type' => 'Student',
202 'Status' => 'New',
203 'Source' => 'Online Contribution: Member Signup and Renewal',
204 );
205 foreach ($verifyMembershipData as $label => $value) {
206 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
207 preg_quote($value)
208 );
209 }
210 }
211
212 /**
213 * FIXME: This test tries to update a contribution page (id=2) that may not exist :(
214 */
215 function testOnlineMembershipRenewChangeType() {
216 // a random 7-char string and an even number to make this pass unique
217 $hash = substr(sha1(rand()), 0, 7);
218 $rand = 2 * rand(2, 50);
219
220 // Log in using webtestLogin() method
221 $this->webtestLogin();
222
223 // Use default payment processor
224 $processorName = 'Test Processor';
225 $this->webtestAddPaymentProcessor($processorName);
226
227 $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next');
228
229 //this contribution page for membership signup
230 $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
231 $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName);
232 $this->check($xpath);
233
234 // save
235 $this->waitForElementPresent('_qf_Amount_next');
236 $this->click('_qf_Amount_next');
237 $this->waitForPageToLoad();
238
239 // go to Membership block
240 $this->click('css=#tab_membership a');
241 $this->waitForElementPresent("member_is_active");
242 $this->check("member_is_active");
243
244 $this->waitForElementPresent("new_title");
245 if ($this->isElementPresent("member_price_set_id")) {
246 $this->waitForElementPresent("member_price_set_id");
247
248 $this->select("member_price_set_id", "label=- none -");
249 }
250
251 $this->waitForElementPresent("membership_type-block");
252 $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]");
253 $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]");
254 $this->click("_qf_MembershipBlock_next-bottom");
255 $this->waitForTextPresent("'MembershipBlock' information has been saved");
256
257 // go to Profiles
258 $this->click('css=#tab_custom a');
259
260 // fill in Profiles
261 $this->waitForElementPresent('custom_pre_id');
262 $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1');
263
264 // save
265 $this->click('_qf_Custom_upload_done');
266 $this->waitForPageToLoad();
267
268 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
269 $lastName = 'An' . substr(sha1(rand()), 0, 7);
270
271 //Go to online membership signup page
272 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
273 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[1]/span/label/span[1][contains(text(),'General')]");
274 //Type first name and last name
275 $this->type("first_name", $firstName);
276 $this->type("last_name", $lastName);
277
278 $this->select("state_province-1", "value=1001");
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->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
297
298 $this->click("_qf_Confirm_next-bottom");
299
300 //Find Member
301 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
302
303 $this->type("sort_name", "$lastName $firstName");
304 $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
305 $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
306 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
307
308 $membershipCreatedId = $this->urlArg('id');
309
310 $memberSince = date('F jS, Y');
311
312 //View Membership Record
313 $verifyMembershipData = array(
314 'Member' => $firstName . ' ' . $lastName,
315 'Membership Type' => 'General',
316 'Status' => 'New',
317 'Source' => 'Online Contribution: Member Signup and Renewal',
318 );
319 foreach ($verifyMembershipData as $label => $value) {
320 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
321 preg_quote($value)
322 );
323 }
324 $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom");
325 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
326
327 //Credit Card Info
328 $this->select("credit_card_type", "value=Visa");
329 $this->select("credit_card_type", "label=Visa");
330 $this->type("credit_card_number", "4111111111111111");
331 $this->type("cvv2", "000");
332 $this->select("credit_card_exp_date[M]", "value=1");
333 $this->select("credit_card_exp_date[Y]", "value=2020");
334 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
335 $this->click("_qf_Confirm_next-bottom");
336
337 //Find Member
338 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
339
340 $this->type("sort_name", "$lastName $firstName");
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');
343 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
344
345 $membershipRenewedId = $this->urlArg('id');
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() {
364 // Log in as admin
365 $this->webtestLogin('admin');
366
367 $this->enableComponents('CiviMember');
368
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
374 $this->webtestLogin();
375
376 $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
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
384 $this->waitForText('crm-notification-container', "Organization $title has been created.");
385
386 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
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");
393
394 $this->select2('member_of_contact_id', $title);
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', 'value=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->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
408
409 $this->waitForElementPresent("xpath=//div[@id='membership_type']/table/tbody//tr/td[1][text()='{$membershipTypeTitle}']/../td[12]/span/a[3][text()='Delete']/@href");
410 $url = $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1][text()='{$membershipTypeTitle}']/../td[12]/span/a[3][text()='Delete']/@href");
411 $matches = array();
412 preg_match('/id=([0-9]+)/', $url, $matches);
413 $membershipTypeId = $matches[1];
414
415 // Use default payment processor
416 $processorName = 'Test Processor';
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("xpath=//input[@id='onbehalf_profile_id']/parent::td/div/div/span/select", "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]/div/span/label/span[1][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 $this->select("state_province-1", "value=1001");
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");
520 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
521
522 $this->click("_qf_Confirm_next-bottom");
523 $this->waitForPageToLoad($this->getTimeoutMsec());
524
525 // Log in using webtestLogin() method
526 $this->webtestLogin();
527
528 //Find member
529 $endDate = date('F jS, Y', strtotime(" +1 year -1 day"));
530 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
531
532 $this->type("sort_name", "$organisationName");
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');
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
551 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
552
553 $this->type("sort_name", "$lastName, $firstName");
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');
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
573 $this->webtestLogout();
574
575 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
576
577 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][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);
591 $this->select("state_province-1", "value=1001");
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
610 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
611
612 $this->click("_qf_Confirm_next-bottom");
613 $this->waitForPageToLoad($this->getTimeoutMsec());
614
615 // Log in using webtestLogin() method
616 $this->webtestLogin();
617
618 //Find member
619 $endDate = date('F jS, Y', strtotime(" +2 year -1 day"));
620 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
621
622 $this->type("sort_name", "$organisationName");
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');
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
640 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
641
642 $this->type("sort_name", "$lastName, $firstName");
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');
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