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