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