Merge pull request #53 from totten/releaser
[civicrm-core.git] / tests / phpunit / WebTest / Member / OnlineMembershipAddPricesetTest.php
CommitLineData
6a488035
TO
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testAddPriceSet() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
38 // class attributes.
39 $this->open($this->sboxPath);
40
41 // Log in using webtestLogin() method
42 $this->webtestLogin();
43
44 // add the required Drupal permission
45
46 $permissions = array('edit-1-make-online-contributions');
47 $this->changePermissions($permissions);
48
49 $title = substr(sha1(rand()), 0, 7);
50 $setTitle = "Membership Fees - $title";
51 $usedFor = 'Membership';
52 $contributionType = 'Donation';
53 $setHelp = 'Select your membership options.';
54 $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
55
56 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
57 // which is where we are after adding Price Set.
58 $elements = $this->parseURL();
59 $sid = $elements['queryString']['sid'];
60 $this->assertType('numeric', $sid);
61
62 $fields = array(
63 "National Membership $title" => 'Radio',
64 "Local Chapter $title" => 'CheckBox',
65 );
66
67 list($memTypeTitle1, $memTypeTitle2) = $this->_testAddPriceFields($fields, $validateStrings, FALSE, $title, $sid, $contributionType);
68 //var_dump($validateStrings);
69
70 // load the Price Set Preview and check for expected values
71 $this->_testVerifyPriceSet($validateStrings, $sid);
72
73 $contributionPageTitle = "Contribution Page $title";
74 $paymentProcessor = "Webtest Dummy $title";
75 $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array($paymentProcessor => 'Dummy'),
76 TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, $sid, FALSE, 1, NULL
77 );
78
79 // Sign up for membership
80 $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle);
81
82 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
83 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
84 $email = "{$firstName}.{$lastName}@example.com";
85
86 $contactParams = array(
87 'first_name' => $firstName,
88 'last_name' => $lastName,
89 'email-5' => $email,
90 );
91 $this->_testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2);
92
93 // Renew this membership
94 $this->_testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = TRUE);
95 }
96
97 function testAddPriceSetWithMultipleTerms() {
98 // This is the path where our testing install resides.
99 // The rest of URL is defined in CiviSeleniumTestCase base class, in
100 // class attributes.
101 $this->open($this->sboxPath);
102
103 // Log in using webtestLogin() method
104 $this->webtestLogin();
105
106 // add the required Drupal permission
107
108 $permissions = array('edit-1-make-online-contributions');
109 $this->changePermissions($permissions);
110
111 $title = substr(sha1(rand()), 0, 7);
112 $setTitle = "Membership Fees - $title";
113 $usedFor = 'Membership';
114 $contributionType = 'Member Dues';
115 $setHelp = 'Select your membership options.';
116 $memTypeParams1 = $this->webtestAddMembershipType();
117 $memTypeTitle1 = $memTypeParams1['membership_type'];
118 $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href"));
119 $memTypeId1 = $memTypeId1[1];
120 $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
121
122 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
123 // which is where we are after adding Price Set.
124 $elements = $this->parseURL();
125 $sid = $elements['queryString']['sid'];
126 $this->assertType('numeric', $sid);
127
128 $fields = array("National Membership $title", "Radio");
129 $this->open($this->sboxPath . "civicrm/admin/price/field?reset=1&action=add&sid={$sid}");
130
131 $validateStrings[] = $fields[0];
132 $this->type('label', $fields[0]);
133 $this->select('html_type', "value={$fields[1]}");
134 $options = array(
135 1 => array('label' => $memTypeTitle1."_1",
136 'membership_type_id' => $memTypeId1,
137 'amount' => 50.00,
138 'membership_num_terms' => 1,
139 ),
140 2 => array(
141 'label' => $memTypeTitle1."_2",
142 'membership_type_id' => $memTypeId1,
143 'amount' => 90.00,
144 'membership_num_terms' => 2,
145 ),
146 3 => array(
147 'label' => $memTypeTitle1."_3",
148 'membership_type_id' => $memTypeId1,
149 'amount' => 120.00,
150 'membership_num_terms' => 3,
151 ),
152
153 );
154 $i = 2;
155 foreach($options as $index => $values){
156 $this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
157 sleep(1);
158 $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input",$values['membership_num_terms']);
159 $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input",$values['label']);
160 $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input",$values['amount']);
161 if($i > 3){
162 $this->click('link=another choice');
163 }
164 $i++;
165 }
166 $this->waitForElementPresent( 'financial_type_id' );
167 $this->select("financial_type_id", "label={$contributionType}");
168 $this->waitForElementPresent('_qf_Field_next-bottom');
169 $this->click('_qf_Field_next-bottom');
170 $this->waitForPageToLoad($this->getTimeoutMsec());
171 $this->assertTrue($this->isTextPresent("Price Field '{$fields[0]}' has been saved."));
172
173 // load the Price Set Preview and check for expected values
174 $this->_testVerifyPriceSet($validateStrings, $sid);
175
176 $contributionPageTitle = "Contribution Page $title";
177 $paymentProcessor = "Webtest Dummy $title";
178 $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array($paymentProcessor => 'Dummy'),
179 TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, $sid, FALSE, 1, NULL
180 );
181
182 // Sign up for membership
183 $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle);
184
185 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
186 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
187 $email = "{$firstName}.{$lastName}@example.com";
188
189 $contactParams = array(
190 'first_name' => $firstName,
191 'last_name' => $lastName,
192 'email-5' => $email,
193 );
194 //membership with number of terms as 2
195 $this->_testMultilpeTermsMembershipRegistration($registerUrl, $contactParams, $memTypeTitle1, 2);
196 //membership with number of terms as 3 which will renew the above membership
197 $this->_testMultilpeTermsMembershipRegistration($registerUrl, $contactParams, $memTypeTitle1, 3, TRUE);
198
199 }
200
201 function _testAddSet($setTitle, $usedFor, $contributionType = NULL, $setHelp) {
202 $this->open($this->sboxPath . 'civicrm/admin/price?reset=1&action=add');
203 $this->waitForPageToLoad($this->getTimeoutMsec());
204 $this->waitForElementPresent('_qf_Set_next-bottom');
205
206 // Enter Priceset fields (Title, Used For ...)
207 $this->type('title', $setTitle);
208 if ($usedFor == 'Event') {
209 $this->check('extends[1]');
210 }
211 elseif ($usedFor == 'Contribution') {
212 $this->check('extends[2]');
213 }
214 elseif ($usedFor == 'Membership') {
215 $this->click('extends[3]');
216 $this->waitForElementPresent( 'financial_type_id' );
217 $this->select("css=select.form-select", "label={$contributionType}");
218 }
219
220 $this->type('help_pre', $setHelp);
221
222 $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
223 $this->click('_qf_Set_next-bottom');
224
225 $this->waitForPageToLoad($this->getTimeoutMsec());
226 $this->waitForElementPresent('_qf_Field_next-bottom');
227 $this->assertTrue($this->isTextPresent("Your Set '{$setTitle}' has been added. You can add fields to this set now."));
228 }
229
230 function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $contributionType) {
231 $memTypeParams1 = $this->webtestAddMembershipType();
232 $memTypeTitle1 = $memTypeParams1['membership_type'];
233 $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href"));
234 $memTypeId1 = $memTypeId1[1];
235
236 $memTypeParams2 = $this->webtestAddMembershipType();
237 $memTypeTitle2 = $memTypeParams2['membership_type'];
238 $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href"));
239 $memTypeId2 = $memTypeId2[1];
240
241 $this->open($this->sboxPath . "civicrm/admin/price/field?reset=1&action=add&sid={$sid}");
242
243 foreach ($fields as $label => $type) {
244 $validateStrings[] = $label;
245
246 $this->type('label', $label);
247 $this->select('html_type', "value={$type}");
248
249 switch ($type) {
250 case 'Radio':
251 $options = array(
252 1 => array('label' => "$memTypeTitle1",
253 'membership_type_id' => $memTypeId1,
254 'amount' => 100.00,
255 ),
256 2 => array(
257 'label' => "$memTypeTitle2",
258 'membership_type_id' => $memTypeId2,
259 'amount' => 50.00,
260 ),
261 );
262 $this->addMultipleChoiceOptions($options, $validateStrings);
263 break;
264
265 case 'CheckBox':
266 $options = array(
267 1 => array('label' => "$memTypeTitle1",
268 'membership_type_id' => $memTypeId1,
269 'amount' => 100.00,
270 ),
271 2 => array(
272 'label' => "$memTypeTitle2",
273 'membership_type_id' => $memTypeId2,
274 'amount' => 50.00,
275 ),
276 );
277 $this->addMultipleChoiceOptions($options, $validateStrings);
278 break;
279
280 default:
281 break;
282 }
283 $this->select("financial_type_id", "label={$contributionType}");
284 $this->click('_qf_Field_next_new-bottom');
285 $this->waitForPageToLoad($this->getTimeoutMsec());
286 $this->waitForElementPresent('_qf_Field_next-bottom');
287 $this->assertTrue($this->isTextPresent("Price Field '{$label}' has been saved."));
288 }
289 return array($memTypeTitle1, $memTypeTitle2);
290 }
291
292 function _testVerifyPriceSet($validateStrings, $sid) {
293 // verify Price Set at Preview page
294 // start at Manage Price Sets listing
295 $this->open($this->sboxPath . 'civicrm/admin/price?reset=1');
296 $this->waitForPageToLoad($this->getTimeoutMsec());
297
298 // Use the price set id ($sid) to pick the correct row
299 $this->click("css=tr#row_{$sid} a[title='Preview Price Set']");
300
301 $this->waitForPageToLoad($this->getTimeoutMsec());
302 // Look for Register button
303 $this->waitForElementPresent('_qf_Preview_cancel-bottom');
304
305 // Check for expected price set field strings
306 $this->assertStringsPresent($validateStrings);
307 }
308
309 function _testVerifyRegisterPage($contributionPageTitle) {
310 $this->open($this->sboxPath . 'civicrm/admin/contribute?reset=1');
311 $this->waitForElementPresent('_qf_SearchContribution_refresh');
312 $this->type('title', $contributionPageTitle);
313 $this->click('_qf_SearchContribution_refresh');
314 $this->waitForPageToLoad('50000');
315 $id = $this->getAttribute("//div[@id='configure_contribution_page']//div[@class='dataTables_wrapper']/table/tbody/tr@id");
316 $id = explode('_', $id);
317 $registerUrl = "civicrm/contribute/transact?reset=1&id=$id[1]";
318 return $registerUrl;
319 }
320
321 function _testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = FALSE) {
322 $this->open($this->sboxPath . 'civicrm/logout?reset=1');
323 $this->waitForPageToLoad($this->getTimeoutMsec());
324
325 $this->open($this->sboxPath . $registerUrl);
326 $this->waitForElementPresent('_qf_Main_upload-bottom');
327
328 //build the membership dates.
329 require_once 'CRM/Core/Config.php';
330 require_once 'CRM/Utils/Array.php';
331 require_once 'CRM/Utils/Date.php';
332 $currentYear = date('Y');
333 $currentMonth = date('m');
334 $previousDay = date('d') - 1;
335 $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1;
336 $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
337 $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
338 $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear));
339 $configVars = new CRM_Core_Config_Variables();
340 foreach (array(
341 'joinDate', 'startDate', 'endDate') as $date) {
342 $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
343 }
344
345 $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div/span/input");
346 $this->click("xpath=//div[@id='priceset']/div[3]/div[2]/div[2]/span/input");
347
348 $this->type('email-5', $contactParams['email-5']);
349 $this->type('first_name', $contactParams['first_name']);
350 $this->type('last_name', $contactParams['last_name']);
351
352 $streetAddress = "100 Main Street";
353 $this->type("street_address-1", $streetAddress);
354 $this->type("city-1", "San Francisco");
355 $this->type("postal_code-1", "94117");
356 $this->select("country-1", "value=1228");
357 $this->select("state_province-1", "value=1001");
358
359 //Credit Card Info
360 $this->select("credit_card_type", "value=Visa");
361 $this->type("credit_card_number", "4111111111111111");
362 $this->type("cvv2", "000");
363 $this->select("credit_card_exp_date[M]", "value=1");
364 $this->select("credit_card_exp_date[Y]", "value=2020");
365
366 //Billing Info
367 $this->type("billing_first_name", $contactParams['first_name'] . "billing");
368 $this->type("billing_last_name", $contactParams['last_name'] . "billing");
369 $this->type("billing_street_address-5", "15 Main St.");
370 $this->type(" billing_city-5", "San Jose");
371 $this->select("billing_country_id-5", "value=1228");
372 $this->select("billing_state_province_id-5", "value=1004");
373 $this->type("billing_postal_code-5", "94129");
374 $this->click("_qf_Main_upload-bottom");
375
376 $this->waitForPageToLoad($this->getTimeoutMsec());
377 $this->waitForElementPresent("_qf_Confirm_next-bottom");
378
379 $this->click("_qf_Confirm_next-bottom");
380 $this->waitForPageToLoad($this->getTimeoutMsec());
381
382 //login to check membership
383 $this->open($this->sboxPath);
384
385 // Log in using webtestLogin() method
386 $this->webtestLogin();
387
388 $this->open($this->sboxPath . "civicrm/member/search?reset=1");
389 $this->waitForElementPresent("member_end_date_high");
390
391 $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
392 $this->click("_qf_Search_refresh");
393
394 $this->waitForPageToLoad($this->getTimeoutMsec());
395 $this->assertTrue($this->isTextPresent("2 Results "));
396
397 $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr");
398 $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']");
399 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
400
401 //View Membership Record
402 $verifyData = array(
403 'Membership Type' => "$memTypeTitle1",
404 'Status' => 'New',
405 'Member Since' => $joinDate,
406 'Start date' => $startDate,
407 'End date' => $endDate,
408 );
409 foreach ($verifyData as $label => $value) {
410 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
411 preg_quote($value)
412 );
413 }
414
415 $this->click('_qf_MembershipView_cancel-bottom');
416 $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr[2]");
417 $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle2}']/../td[11]/span/a[text()='View']");
418 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
419
420 //View Membership Record
421 $verifyData = array(
422 'Membership Type' => "$memTypeTitle2",
423 'Status' => 'New',
424 'Member Since' => $joinDate,
425 'Start date' => $startDate,
426 'End date' => $endDate,
427 );
428 foreach ($verifyData as $label => $value) {
429 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
430 preg_quote($value)
431 );
432 }
433 }
434
435 function _testMultilpeTermsMembershipRegistration($registerUrl, $contactParams, $memTypeTitle1, $term, $renew = FALSE){
436 if($renew){
437 $this->open($this->sboxPath . "civicrm/member/search?reset=1");
438 $this->waitForElementPresent("member_end_date_high");
439 $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
440 $this->click("_qf_Search_refresh");
441 $this->waitForPageToLoad($this->getTimeoutMsec());
442 $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr");
443 $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']");
444 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
445 $year = CRM_Utils_Date::processDate($this->getText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='End date']/following-sibling::td"));
446 $prevYear = substr($year, 0, 4);
447 }
448
449 $this->open($this->sboxPath . 'civicrm/logout?reset=1');
450 $this->waitForPageToLoad($this->getTimeoutMsec());
451
452 $this->open($this->sboxPath . $registerUrl);
453 $this->waitForElementPresent('_qf_Main_upload-bottom');
454
455 //build the membership dates.
456 require_once 'CRM/Core/Config.php';
457 require_once 'CRM/Utils/Array.php';
458 require_once 'CRM/Utils/Date.php';
459 $currentYear = date('Y');
460 $currentMonth = date('m');
461 $previousDay = date('d') - 1;
462 $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1);
463 $endYear = ($renew) ? $endYear + ($prevYear - $currentYear) : $endYear;
464 $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
465 $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
466 $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear));
467 $configVars = new CRM_Core_Config_Variables();
468 foreach (array(
469 'joinDate', 'startDate', 'endDate') as $date) {
470 $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
471 }
472 $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1 );
473 $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input");
474 $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input");
475 $amount = $this->getText("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/label/span[@class='crm-price-amount-amount']");
476
477 $this->type('email-5', $contactParams['email-5']);
478 $this->type('first_name', $contactParams['first_name']);
479 $this->type('last_name', $contactParams['last_name']);
480
481 $streetAddress = "100 Main Street";
482 $this->type("street_address-1", $streetAddress);
483 $this->type("city-1", "San Francisco");
484 $this->type("postal_code-1", "94117");
485 $this->select("country-1", "value=1228");
486 $this->select("state_province-1", "value=1001");
487
488 //Credit Card Info
489 $this->select("credit_card_type", "value=Visa");
490 $this->type("credit_card_number", "4111111111111111");
491 $this->type("cvv2", "000");
492 $this->select("credit_card_exp_date[M]", "value=1");
493 $this->select("credit_card_exp_date[Y]", "value=2020");
494
495 //Billing Info
496 $this->type("billing_first_name", $contactParams['first_name'] . "billing");
497 $this->type("billing_last_name", $contactParams['last_name'] . "billing");
498 $this->type("billing_street_address-5", "15 Main St.");
499 $this->type(" billing_city-5", "San Jose");
500 $this->select("billing_country_id-5", "value=1228");
501 $this->select("billing_state_province_id-5", "value=1004");
502 $this->type("billing_postal_code-5", "94129");
503 $this->click("_qf_Main_upload-bottom");
504
505 $this->waitForPageToLoad($this->getTimeoutMsec());
506 $this->waitForElementPresent("_qf_Confirm_next-bottom");
507
508 $this->click("_qf_Confirm_next-bottom");
509 $this->waitForPageToLoad($this->getTimeoutMsec());
510
511 //login to check membership
512 $this->open($this->sboxPath);
513
514 // Log in using webtestLogin() method
515 $this->webtestLogin();
516
517 $this->open($this->sboxPath . "civicrm/member/search?reset=1");
518 $this->waitForElementPresent("member_end_date_high");
519
520 $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
521 $this->click("_qf_Search_refresh");
522
523 $this->waitForPageToLoad($this->getTimeoutMsec());
524 $this->assertTrue($this->isTextPresent("1 Result "));
525
526 $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr");
527 $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']");
528 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
529
530 //View Membership Record
531 $verifyData = array(
532 'Membership Type' => "$memTypeTitle1",
533 'Status' => 'New',
534 'Member Since' => $joinDate,
535 'Start date' => $startDate,
536 'End date' => $endDate,
537 );
538 foreach ($verifyData as $label => $value) {
539 $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
540 preg_quote($value)
541 );
542 }
543 //check if the membership amount is correct
544 $this->assertTrue($this->isElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/table[2]/tbody/tr/td/span[text()='{$amount}']"));
545 }
546
547}
548