Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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_OnlineMembershipCreateTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testOnlineMembershipCreate() { |
6a488035 TO |
39 | //check for online contribution and profile listings permissions |
40 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); | |
41 | $this->changePermissions($permissions); | |
42 | ||
42daf119 CW |
43 | // Log in as normal user |
44 | $this->webtestLogin(); | |
6a488035 TO |
45 | |
46 | // a random 7-char string and an even number to make this pass unique | |
47 | $hash = substr(sha1(rand()), 0, 7); | |
48 | $rand = 2 * rand(2, 50); | |
6a488035 | 49 | |
c3ad8633 CW |
50 | // Use default payment processor |
51 | $processorName = 'Test Processor'; | |
6a488035 TO |
52 | |
53 | // create contribution page with randomized title and default params | |
42daf119 CW |
54 | $amountSection = TRUE; |
55 | $payLater = TRUE; | |
10525e44 | 56 | $allowOtherAmount = FALSE; |
42daf119 CW |
57 | $onBehalf = FALSE; |
58 | $pledges = FALSE; | |
59 | $recurring = FALSE; | |
60 | $memberships = TRUE; | |
61 | $memPriceSetId = NULL; | |
62 | $friend = TRUE; | |
63 | $profilePreId = 1; | |
64 | $profilePostId = NULL; | |
65 | $premiums = TRUE; | |
66 | $widget = FALSE; | |
67 | $pcp = TRUE; | |
6a488035 TO |
68 | $isSeparatePayment = TRUE; |
69 | $contributionTitle = "Title $hash"; | |
42daf119 | 70 | $pageId = $this->webtestAddContributionPage($hash, |
6a488035 TO |
71 | $rand, |
72 | $contributionTitle, | |
73 | array($processorName => 'Dummy'), | |
74 | $amountSection, | |
75 | $payLater, | |
76 | $onBehalf, | |
77 | $pledges, | |
78 | $recurring, | |
79 | $memberships, | |
80 | $memPriceSetId, | |
81 | $friend, | |
82 | $profilePreId, | |
83 | $profilePostId, | |
84 | $premiums, | |
85 | $widget, | |
86 | $pcp, | |
87 | TRUE, | |
88 | FALSE, | |
89 | $isSeparatePayment, | |
90 | TRUE, | |
91 | FALSE | |
92 | ); | |
93 | ||
6a488035 TO |
94 | // create two new membership types |
95 | $memTypeParams1 = $this->webtestAddMembershipType(); | |
42daf119 | 96 | $memTypeTitle1 = $memTypeParams1['membership_type']; |
5c80555f | 97 | $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); |
42daf119 | 98 | $memTypeId1 = $memTypeId1[1]; |
6a488035 TO |
99 | |
100 | $memTypeParams2 = $this->webtestAddMembershipType(); | |
42daf119 | 101 | $memTypeTitle2 = $memTypeParams2['membership_type']; |
5c80555f | 102 | $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href")); |
42daf119 | 103 | $memTypeId2 = $memTypeId2[1]; |
6a488035 TO |
104 | |
105 | // edit contribution page memberships tab to add two new membership types | |
1019390e | 106 | $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_next-bottom'); |
6a488035 TO |
107 | $this->click("membership_type_$memTypeId1"); |
108 | $this->click("membership_type_$memTypeId2"); | |
225a8648 | 109 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); |
6a488035 | 110 | $text = "'MembershipBlock' information has been saved."; |
6c5f7368 | 111 | $this->waitForText('crm-notification-container', $text); |
76e86fd8 | 112 | |
6a488035 | 113 | //logout |
42daf119 | 114 | $this->webtestLogout(); |
6a488035 TO |
115 | |
116 | // signup for membership 1 | |
117 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
118 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
119 | ||
120 | $this->_testOnlineMembershipSignup($pageId, $memTypeTitle1, $firstName, $lastName, $payLater, $hash); | |
6a488035 TO |
121 | |
122 | // Log in using webtestLogin() method | |
123 | $this->webtestLogin(); | |
124 | ||
125 | //Find Member | |
1019390e | 126 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
f1224701 | 127 | $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]"); |
6080c83e | 128 | $this->type("sort_name", "$lastName $firstName"); |
225a8648 | 129 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr"); |
933ee1e4 | 130 | $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='View']"); |
6a488035 TO |
131 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
132 | ||
133 | //View Membership Record | |
134 | $verifyData = array( | |
135 | 'Member' => $firstName . ' ' . $lastName, | |
136 | 'Membership Type' => $memTypeTitle1, | |
137 | 'Source' => 'Online Contribution:' . ' ' . $contributionTitle, | |
b34861f3 | 138 | 'Status' => 'Pending', |
6a488035 | 139 | ); |
96e6d962 | 140 | $this->webtestVerifyTabularData($verifyData); |
6a488035 TO |
141 | |
142 | // Click View action link on associated contribution record | |
343688b7 RK |
143 | $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[1][text()='View']"); |
144 | $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[1][text()='View']"); | |
a7011f01 | 145 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
6a488035 TO |
146 | //View Contribution Record |
147 | $verifyData = array( | |
148 | 'From' => $firstName . ' ' . $lastName, | |
149 | 'Total Amount' => '$ 100.00', | |
b34861f3 | 150 | 'Contribution Status' => 'Pending : Pay Later', |
6a488035 | 151 | ); |
96e6d962 | 152 | $this->webtestVerifyTabularData($verifyData); |
6a488035 | 153 | |
75339f53 | 154 | //CRM-15735 - verify membership dates gets changed w.r.t receive_date of contribution. |
b34861f3 | 155 | $receiveDate = date('F jS, Y', strtotime("-1 month")); |
156 | $endDate = date('F jS, Y', strtotime("+1 year -1 month -1 day")); | |
157 | $this->clickAjaxLink("xpath=//button//span[contains(text(),'Edit')]", 'receive_date'); | |
158 | $this->select('contribution_status_id', 'Completed'); | |
159 | $this->webtestFillDate('receive_date', '-1 month'); | |
160 | $this->clickAjaxLink("xpath=//button//span[contains(text(),'Save')]", "xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]"); | |
161 | $updatedData = array( | |
162 | 'Status' => 'New', | |
163 | 'Member Since' => $receiveDate, | |
164 | 'Start date' => $receiveDate, | |
165 | 'End date' => $endDate, | |
166 | ); | |
167 | $this->webtestVerifyTabularData($updatedData); | |
75339f53 | 168 | |
6a488035 TO |
169 | // CRM-8141 signup for membership 2 with same anonymous user info (should create 2 separate membership records because membership orgs are different) |
170 | //logout | |
42daf119 | 171 | $this->webtestLogout(); |
6a488035 TO |
172 | |
173 | $this->_testOnlineMembershipSignup($pageId, $memTypeTitle2, $firstName, $lastName, $payLater, $hash); | |
6a488035 TO |
174 | |
175 | // Log in using webtestLogin() method | |
176 | $this->webtestLogin(); | |
177 | ||
178 | //Find Member | |
1019390e | 179 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 | 180 | |
6080c83e | 181 | $this->type("sort_name", "$lastName $firstName"); |
810fa73d | 182 | $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]"); |
6a488035 TO |
183 | $this->click("_qf_Search_refresh"); |
184 | ||
185 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
96e6d962 | 186 | $this->assertElementContainsText('search-status', '2 Results', 'Missing text: ' . '2 Results'); |
6a488035 TO |
187 | } |
188 | ||
4cbe18b8 | 189 | /** |
ea3ddccf | 190 | * Test online membership signup. |
191 | * | |
100fef9d CW |
192 | * @param int $pageId |
193 | * @param int $memTypeId | |
194 | * @param string $firstName | |
195 | * @param string $lastName | |
ea3ddccf | 196 | * @param bool $payLater |
197 | * @param string $hash | |
4cbe18b8 | 198 | * @param bool $otherAmount |
ea3ddccf | 199 | * @param bool $amountSection |
200 | * @param bool $freeMembership | |
4cbe18b8 | 201 | */ |
6de2d1f6 | 202 | public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE, $onBehalf = FALSE, $onBehalfParams = array()) { |
6a488035 | 203 | //Open Live Contribution Page |
f1224701 | 204 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom"); |
6a488035 TO |
205 | // Select membership type 1 |
206 | $this->waitForElementPresent("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label"); | |
1019390e | 207 | if ($memTypeId != 'No thank you') { |
6c6e6187 | 208 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//div/span/label/span[1][contains(text(),'$memTypeId')]"); |
76e86fd8 | 209 | } |
1019390e | 210 | else { |
76e86fd8 | 211 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label[contains(text(),'$memTypeId')]"); |
1019390e | 212 | } |
4da07767 | 213 | if (!$otherAmount && $amountSection) { |
1019390e PN |
214 | $this->click("xpath=//div[@class='crm-section contribution_amount-section']/div[2]//span/label[text()='No thank you']"); |
215 | } | |
4da07767 | 216 | elseif ($amountSection) { |
b34861f3 | 217 | $this->clickAt("xpath=//div[@class='content other_amount-content']/input"); |
218 | $this->keyDown("xpath=//div[@class='content other_amount-content']/input", " "); | |
1019390e | 219 | $this->type("xpath=//div[@class='content other_amount-content']/input", $otherAmount); |
b34861f3 | 220 | $this->typeKeys("xpath=//div[@class='content other_amount-content']/input", $otherAmount); |
1019390e | 221 | } |
6a488035 | 222 | if ($payLater) { |
933ee1e4 | 223 | $this->waitForAjaxContent(); |
b34861f3 | 224 | $this->click("xpath=//label[text()='Pay later label {$hash}']"); |
6a488035 | 225 | } |
6de2d1f6 | 226 | if ($onBehalf && $onBehalfParams) { |
8cea970d E |
227 | if ($onBehalfParams['mode'] == 'optional') { |
228 | $this->click("is_for_organization"); | |
229 | } | |
6de2d1f6 E |
230 | $this->type("onbehalf[organization_name]", $onBehalfParams['org_name']); |
231 | $this->type("onbehalf[phone-3-1]", $onBehalfParams['org_phone']); | |
232 | $this->type("onbehalf[email-3]", $onBehalfParams['org_email']); | |
233 | $this->type("onbehalf[street_address-3]", "100 Main Street"); | |
234 | $this->type("onbehalf[city-3]", "San Francisco"); | |
235 | $this->type("onbehalf[postal_code-3]", $onBehalfParams['org_postal_code']); | |
236 | $this->select("onbehalf[country-3]", "value=1228"); | |
237 | $this->select("onbehalf[state_province-3]", "value=1001"); | |
238 | } | |
6a488035 | 239 | $this->type("email-5", $firstName . "@example.com"); |
343688b7 | 240 | $this->waitForElementPresent("first_name"); |
6a488035 | 241 | $this->type("first_name", $firstName); |
343688b7 | 242 | $this->waitForElementPresent("last_name"); |
6a488035 TO |
243 | $this->type("last_name", $lastName); |
244 | ||
245 | $streetAddress = "100 Main Street"; | |
343688b7 | 246 | $this->waitForElementPresent("street_address-1"); |
6a488035 TO |
247 | $this->type("street_address-1", $streetAddress); |
248 | $this->type("city-1", "San Francisco"); | |
249 | $this->type("postal_code-1", "94117"); | |
250 | $this->select("country-1", "value=1228"); | |
251 | $this->select("state_province-1", "value=1001"); | |
599e7e41 | 252 | |
253 | if ($freeMembership) { | |
254 | $this->waitForElementPresent("xpath=//div[@id='payment_information'][@style='display: none;']"); | |
255 | } | |
256 | else { | |
257 | if (!$payLater && $amountSection) { | |
b34861f3 | 258 | $this->click("xpath=//label[text()='Test Processor']"); |
259 | $this->waitForAjaxContent(); | |
599e7e41 | 260 | //Credit Card Info |
261 | $this->select("credit_card_type", "value=Visa"); | |
262 | $this->type("credit_card_number", "4111111111111111"); | |
263 | $this->type("cvv2", "000"); | |
264 | $this->select("credit_card_exp_date[M]", "value=1"); | |
265 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
266 | ||
267 | //Billing Info | |
268 | $this->waitForElementPresent("billing_first_name"); | |
269 | $this->type("billing_first_name", $firstName . "billing"); | |
270 | $this->waitForElementPresent("billing_last_name"); | |
271 | $this->type("billing_last_name", $lastName . "billing"); | |
272 | $this->type("billing_street_address-5", "15 Main St."); | |
273 | $this->type(" billing_city-5", "San Jose"); | |
274 | $this->select("billing_country_id-5", "value=1228"); | |
275 | $this->select("billing_state_province_id-5", "value=1004"); | |
276 | $this->type("billing_postal_code-5", "94129"); | |
277 | } | |
6a488035 TO |
278 | } |
279 | $this->click("_qf_Main_upload-bottom"); | |
6a488035 TO |
280 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); |
281 | ||
282 | $this->click("_qf_Confirm_next-bottom"); | |
283 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
284 | } | |
76e86fd8 | 285 | |
00be9182 | 286 | public function testOnlineMembershipCreateWithContribution() { |
1019390e | 287 | //login with admin credentials & make sure we do have required permissions. |
42daf119 CW |
288 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); |
289 | $this->changePermissions($permissions); | |
290 | ||
1019390e PN |
291 | $hash = substr(sha1(rand()), 0, 7); |
292 | $rand = 2 * rand(2, 50); | |
c3ad8633 CW |
293 | // Use default payment processor |
294 | $processorName = 'Test Processor'; | |
42daf119 CW |
295 | $amountSection = TRUE; |
296 | $payLater = TRUE; | |
10525e44 | 297 | $allowOtherAmount = TRUE; |
42daf119 CW |
298 | $onBehalf = FALSE; |
299 | $pledges = FALSE; | |
300 | $recurring = FALSE; | |
301 | $memberships = TRUE; | |
302 | $memPriceSetId = NULL; | |
303 | $friend = FALSE; | |
304 | $profilePreId = 1; | |
305 | $profilePostId = NULL; | |
306 | $premiums = FALSE; | |
307 | $widget = FALSE; | |
308 | $pcp = FALSE; | |
1019390e PN |
309 | $isSeparatePayment = FALSE; |
310 | $membershipsRequired = FALSE; | |
42daf119 | 311 | $fixedAmount = FALSE; |
1019390e | 312 | $contributionTitle = "Title $hash"; |
42daf119 | 313 | $pageId = $this->webtestAddContributionPage($hash, |
1019390e PN |
314 | $rand, |
315 | $contributionTitle, | |
316 | array($processorName => 'Dummy'), | |
317 | $amountSection, | |
318 | $payLater, | |
319 | $onBehalf, | |
320 | $pledges, | |
321 | $recurring, | |
322 | $memberships, | |
323 | $memPriceSetId, | |
324 | $friend, | |
325 | $profilePreId, | |
326 | $profilePostId, | |
327 | $premiums, | |
328 | $widget, | |
329 | $pcp, | |
330 | TRUE, | |
331 | FALSE, | |
332 | $isSeparatePayment, | |
333 | TRUE, | |
10525e44 | 334 | $allowOtherAmount, |
1019390e PN |
335 | TRUE, |
336 | 'Donation', | |
337 | $fixedAmount, | |
96e6d962 | 338 | $membershipsRequired |
1019390e PN |
339 | ); |
340 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
341 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
96e6d962 | 342 | |
1019390e | 343 | //logout |
42daf119 | 344 | $this->webtestLogout(); |
96e6d962 | 345 | |
1019390e | 346 | $this->_testOnlineMembershipSignup($pageId, 'No thank you', $firstName, $lastName, FALSE, $hash, 50); |
96e6d962 | 347 | |
1019390e | 348 | // Log in using webtestLogin() method |
96e6d962 | 349 | $this->webtestLogin(); |
1019390e PN |
350 | |
351 | //Find Contribution | |
6c6e6187 | 352 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
1019390e | 353 | |
6080c83e | 354 | $this->type("sort_name", "$lastName $firstName"); |
f1224701 | 355 | $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]"); |
933ee1e4 | 356 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
b34861f3 | 357 | |
358 | // assert financial data - CRM-17863 | |
359 | $this->waitForElementPresent("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']"); | |
360 | $this->click("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']"); | |
361 | $this->waitForAjaxContent(); | |
362 | $verifyFinancialData = array( | |
363 | 1 => '50.00', | |
364 | 2 => 'Donation', | |
365 | 6 => 'Completed', | |
366 | ); | |
2986daf1 | 367 | foreach ($verifyFinancialData as $col => $data) { |
b34861f3 | 368 | $this->verifyText("xpath=//tr[@class='crm-child-row']/td/div/table/tbody/tr[2]/td[{$col}]", $data); |
369 | } | |
933ee1e4 | 370 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); |
1019390e PN |
371 | |
372 | //View Contribution Record and verify data | |
373 | $expected = array( | |
374 | 'From' => "{$firstName} {$lastName}", | |
375 | 'Financial Type' => 'Donation', | |
376 | 'Total Amount' => '50.00', | |
377 | 'Contribution Status' => 'Completed', | |
378 | 'Received Into' => 'Deposit Bank Account', | |
379 | 'Source' => "Online Contribution: $contributionTitle", | |
380 | 'Online Contribution Page' => $contributionTitle, | |
381 | ); | |
382 | $this->webtestVerifyTabularData($expected); | |
383 | } | |
96025800 | 384 | |
93ba05e3 | 385 | /** |
5bb12682 | 386 | * CRM-16302 - To check whether membership, contribution are |
387 | * created for free membership signup. | |
8cb616f6 | 388 | */ |
4da07767 | 389 | public function testOnlineMembershipCreateWithZeroContribution() { |
390 | //login with admin credentials & make sure we do have required permissions. | |
391 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); | |
392 | $this->changePermissions($permissions); | |
393 | ||
394 | $hash = substr(sha1(rand()), 0, 7); | |
395 | $rand = 2 * rand(2, 50); | |
6de2d1f6 | 396 | $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = FALSE; |
8cb616f6 | 397 | $premiums = $widget = $pcp = $isSeparatePayment = $membershipsRequired = $fixedAmount = $friend = FALSE; |
4da07767 | 398 | $memberships = TRUE; |
399 | $memPriceSetId = NULL; | |
6de2d1f6 | 400 | $onBehalf = TRUE; |
4da07767 | 401 | $profilePreId = 1; |
402 | $profilePostId = NULL; | |
4da07767 | 403 | $contributionTitle = "Title $hash"; |
404 | $pageId = $this->webtestAddContributionPage($hash, | |
405 | $rand, | |
406 | $contributionTitle, | |
407 | NULL, | |
408 | $amountSection, | |
409 | $payLater, | |
410 | $onBehalf, | |
411 | $pledges, | |
412 | $recurring, | |
413 | $memberships, | |
414 | $memPriceSetId, | |
415 | $friend, | |
416 | $profilePreId, | |
417 | $profilePostId, | |
418 | $premiums, | |
419 | $widget, | |
420 | $pcp, | |
421 | FALSE, | |
422 | FALSE, | |
423 | $isSeparatePayment, | |
424 | FALSE, | |
425 | $allowOtherAmount, | |
426 | TRUE, | |
427 | 'Member Dues', | |
428 | $fixedAmount, | |
429 | $membershipsRequired | |
430 | ); | |
431 | $memTypeParams = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 0); | |
432 | $memTypeTitle = $memTypeParams['membership_type']; | |
433 | $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle}']/../../td[12]/span/a[3]@href")); | |
434 | $memTypeId = $memTypeId[1]; | |
435 | ||
436 | // edit contribution page amounts tab to uncheck real time monetary transaction | |
437 | $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_next-bottom'); | |
438 | $this->click("membership_type_$memTypeId"); | |
439 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); | |
440 | $text = "'MembershipBlock' information has been saved."; | |
441 | $this->waitForText('crm-notification-container', $text); | |
4da07767 | 442 | |
599e7e41 | 443 | $processors = array( |
444 | 'Test Processor', | |
445 | 'AuthNet', | |
446 | 'PayPal', | |
447 | 'PayPal_Standard', | |
4da07767 | 448 | ); |
599e7e41 | 449 | foreach ($processors as $processor) { |
450 | if ($processor == 'Test Processor') { | |
451 | $processorName = $processor; | |
452 | } | |
453 | else { | |
454 | $processorName = $processor . substr(sha1(rand()), 0, 7); | |
455 | $this->webtestAddPaymentProcessor($processorName, $processor); | |
456 | } | |
457 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id={$pageId}", '_qf_Amount_upload_done-bottom'); | |
458 | $this->assertTrue($this->isTextPresent($processorName)); | |
459 | $this->check("xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"); | |
460 | $this->clickLink('_qf_Amount_upload_done-bottom'); | |
461 | $this->waitForText('crm-notification-container', "'Amount' information has been saved."); | |
462 | ||
463 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
464 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
465 | ||
466 | //logout | |
467 | $this->webtestLogout(); | |
468 | ||
469 | $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE); | |
470 | ||
471 | // Log in using webtestLogin() method | |
472 | $this->webtestLogin(); | |
473 | ||
474 | //Find Contribution | |
475 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); | |
476 | $this->type("sort_name", "$lastName $firstName"); | |
ef7308e8 | 477 | $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]"); |
4dc8abb7 | 478 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
b34861f3 | 479 | |
480 | // assert financial data - CRM-17863 | |
481 | $this->waitForElementPresent("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']"); | |
482 | $this->click("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']"); | |
483 | $this->waitForAjaxContent(); | |
484 | $verifyFinancialData = array( | |
485 | 1 => '0.00', | |
486 | 2 => 'Member Dues', | |
487 | 3 => 'Credit Card', | |
488 | 6 => 'Completed', | |
489 | ); | |
2986daf1 | 490 | foreach ($verifyFinancialData as $col => $data) { |
b34861f3 | 491 | $this->verifyText("xpath=//tr[@class='crm-child-row']/td/div/table/tbody/tr[2]/td[{$col}]", $data); |
492 | } | |
4dc8abb7 | 493 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); |
599e7e41 | 494 | |
495 | //View Contribution Record and verify data | |
496 | $expected = array( | |
497 | 'From' => "{$firstName} {$lastName}", | |
ef7308e8 | 498 | 'Financial Type' => 'Member Dues (test) ', |
599e7e41 | 499 | 'Total Amount' => '0.00', |
500 | 'Contribution Status' => 'Completed', | |
599e7e41 | 501 | 'Source' => "Online Contribution: $contributionTitle", |
502 | 'Online Contribution Page' => $contributionTitle, | |
503 | ); | |
504 | $this->webtestVerifyTabularData($expected); | |
4da07767 | 505 | |
599e7e41 | 506 | //Find Member |
507 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); | |
ef7308e8 | 508 | $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]"); |
4da07767 | 509 | |
599e7e41 | 510 | $this->type("sort_name", "$lastName $firstName"); |
511 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr"); | |
933ee1e4 | 512 | $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='View']"); |
599e7e41 | 513 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
4da07767 | 514 | |
599e7e41 | 515 | //View Membership Record |
516 | $verifyData = array( | |
517 | 'Member' => $firstName . ' ' . $lastName, | |
518 | 'Membership Type' => $memTypeTitle, | |
519 | 'Source' => 'Online Contribution:' . ' ' . $contributionTitle, | |
520 | 'Status' => 'New', | |
521 | ); | |
4da07767 | 522 | |
599e7e41 | 523 | $this->webtestVerifyTabularData($verifyData); |
524 | } | |
4da07767 | 525 | } |
526 | ||
8cea970d E |
527 | /** |
528 | * CRM-18163 - To check whether multiple organizations with same name | |
529 | * are created based on dedupe rule other than org name. | |
530 | */ | |
6de2d1f6 E |
531 | public function testOnlineMembershipCreateOnBehalfWithOrgDedupe() { |
532 | // Add unsupervised dedupe rule. | |
533 | $this->webtestLogin(); | |
534 | $this->openCiviPage("contact/deduperules", "reset=1"); | |
535 | $this->waitForElementPresent("xpath=//div[@id='option13_wrapper']/table/tbody/tr[2]/td[3]/span/a[2][text()='Edit Rule']"); | |
536 | $this->click("xpath=//div[@id='option13_wrapper']/table/tbody/tr[2]/td[3]/span/a[2][text()='Edit Rule']"); | |
537 | $this->waitForElementPresent('_qf_DedupeRules_next'); | |
f5a16a23 | 538 | |
6de2d1f6 E |
539 | $this->type('title', "Postal Code unsupervised dedupe rule"); |
540 | $this->click('CIVICRM_QFID_Unsupervised_used'); | |
541 | $this->select('where_0', "Organization Name"); | |
542 | $this->type('weight_0', 10); | |
543 | $this->select('where_1', "Postal Code"); | |
544 | $this->type('length_1', 3); | |
545 | $this->type('weight_1', 10); | |
546 | $this->type('threshold', 20); | |
547 | $this->click('_qf_DedupeRules_next'); | |
548 | $this->webtestLogout(); | |
549 | ||
550 | //login with admin credentials & make sure we do have required permissions. | |
551 | $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); | |
552 | $this->changePermissions($permissions); | |
553 | ||
554 | $hash = substr(sha1(rand()), 0, 7); | |
555 | $rand = 2 * rand(2, 50); | |
556 | $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = $membershipsRequired = FALSE; | |
557 | $premiums = $widget = $pcp = $isSeparatePayment = $fixedAmount = $friend = FALSE; | |
558 | $memberships = FALSE; | |
559 | $memPriceSetId = NULL; | |
560 | $profilePreId = 1; | |
f5a16a23 | 561 | $profilePostId = NULL; |
8cea970d | 562 | $onBehalf = 'optional'; |
6de2d1f6 E |
563 | $contributionTitle = "Title $hash"; |
564 | $pageId = $this->webtestAddContributionPage( | |
565 | $hash, | |
566 | $rand, | |
567 | $contributionTitle, | |
568 | NULL, | |
569 | $amountSection, | |
570 | $payLater, | |
571 | $onBehalf, | |
572 | $pledges, | |
573 | $recurring, | |
574 | $memberships, | |
575 | $memPriceSetId, | |
576 | $friend, | |
577 | $profilePreId, | |
578 | $profilePostId, | |
579 | $premiums, | |
580 | $widget, | |
581 | $pcp, | |
582 | FALSE, | |
583 | FALSE, | |
584 | $isSeparatePayment, | |
585 | FALSE, | |
586 | $allowOtherAmount, | |
587 | TRUE, | |
588 | 'Member Dues', | |
589 | $fixedAmount, | |
590 | $membershipsRequired | |
591 | ); | |
592 | $memTypeParams = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 0); | |
593 | $memTypeTitle = $memTypeParams['membership_type']; | |
594 | $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle}']/../../td[12]/span/a[3]@href")); | |
595 | $memTypeId = $memTypeId[1]; | |
596 | ||
6de2d1f6 E |
597 | $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_submit_savenext'); |
598 | $this->click('member_is_active'); | |
599 | $this->waitForElementPresent('displayFee'); | |
600 | $this->type('new_title', "Title - New Membership $hash"); | |
601 | $this->type('renewal_title', "Title - Renewals $hash"); | |
602 | $this->click("membership_type_$memTypeId"); | |
603 | $this->clickLink('_qf_MembershipBlock_submit_savenext'); | |
604 | ||
605 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
606 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
f5a16a23 | 607 | |
6de2d1f6 | 608 | $onBehalfParams = array( |
8cea970d | 609 | 'org_name' => 'Test Org Dedupe', // Same Org Name. |
6de2d1f6 | 610 | 'org_phone' => '123-456-789', |
8cea970d | 611 | 'org_email' => 'testorgdedupe@test.com', // Same Email address. |
6de2d1f6 | 612 | 'org_postal_code' => 'ABC 123', |
8cea970d | 613 | 'mode' => 'optional', |
6de2d1f6 | 614 | ); |
f5a16a23 | 615 | |
6de2d1f6 E |
616 | $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE, TRUE, $onBehalfParams); |
617 | $onBehalfParams['org_postal_code'] = 'XYZ 123'; | |
618 | $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE, TRUE, $onBehalfParams); | |
f5a16a23 | 619 | |
6de2d1f6 | 620 | $this->webtestLogin(); |
8cea970d E |
621 | $this->openCiviPage("contact/search", "reset=1"); |
622 | $this->waitForElementPresent("_qf_Basic_refresh"); | |
623 | $this->type('sort_name', $onBehalfParams['org_email']); | |
624 | $this->click("_qf_Basic_refresh"); | |
625 | $this->waitForElementPresent("xpath=//div[@class='crm-search-results']"); | |
626 | $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/label[1]", "All 2 records"); | |
6de2d1f6 E |
627 | } |
628 | ||
42daf119 | 629 | } |