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