Merge pull request #10630 from tschuettler/CRM-CRM-20841
[civicrm-core.git] / tests / phpunit / WebTest / Member / OnlineMembershipCreateTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Member_OnlineMembershipCreateTest
31 */
32 class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testOnlineMembershipCreate() {
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
43 // Log in as normal user
44 $this->webtestLogin();
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);
49
50 // Use default payment processor
51 $processorName = 'Test Processor';
52
53 // create contribution page with randomized title and default params
54 $amountSection = TRUE;
55 $payLater = TRUE;
56 $allowOtherAmount = FALSE;
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;
68 $isSeparatePayment = TRUE;
69 $contributionTitle = "Title $hash";
70 $pageId = $this->webtestAddContributionPage($hash,
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
94 // create two new membership types
95 $memTypeParams1 = $this->webtestAddMembershipType();
96 $memTypeTitle1 = $memTypeParams1['membership_type'];
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"));
98 $memTypeId1 = $memTypeId1[1];
99
100 $memTypeParams2 = $this->webtestAddMembershipType();
101 $memTypeTitle2 = $memTypeParams2['membership_type'];
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"));
103 $memTypeId2 = $memTypeId2[1];
104
105 // edit contribution page memberships tab to add two new membership types
106 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_next-bottom');
107 $this->click("membership_type_$memTypeId1");
108 $this->click("membership_type_$memTypeId2");
109 $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
110 $text = "'MembershipBlock' information has been saved.";
111 $this->waitForText('crm-notification-container', $text);
112
113 //logout
114 $this->webtestLogout();
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);
121
122 // Log in using webtestLogin() method
123 $this->webtestLogin();
124
125 //Find Member
126 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
127 $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
128 $this->type("sort_name", "$lastName $firstName");
129 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
130 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='View']");
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,
138 'Status' => 'Pending',
139 );
140 $this->webtestVerifyTabularData($verifyData);
141
142 // Click View action link on associated contribution record
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']");
145 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
146 //View Contribution Record
147 $verifyData = array(
148 'From' => $firstName . ' ' . $lastName,
149 'Total Amount' => '$ 100.00',
150 'Contribution Status' => 'Pending : Pay Later',
151 );
152 $this->webtestVerifyTabularData($verifyData);
153
154 //CRM-15735 - verify membership dates gets changed w.r.t receive_date of contribution.
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);
168
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
171 $this->webtestLogout();
172
173 $this->_testOnlineMembershipSignup($pageId, $memTypeTitle2, $firstName, $lastName, $payLater, $hash);
174
175 // Log in using webtestLogin() method
176 $this->webtestLogin();
177
178 //Find Member
179 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
180
181 $this->type("sort_name", "$lastName $firstName");
182 $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
183 $this->click("_qf_Search_refresh");
184
185 $this->waitForPageToLoad($this->getTimeoutMsec());
186 $this->assertElementContainsText('search-status', '2 Results', 'Missing text: ' . '2 Results');
187 }
188
189 /**
190 * Test online membership signup.
191 *
192 * @param int $pageId
193 * @param int $memTypeId
194 * @param string $firstName
195 * @param string $lastName
196 * @param bool $payLater
197 * @param string $hash
198 * @param bool $otherAmount
199 * @param bool $amountSection
200 * @param bool $freeMembership
201 */
202 public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE, $onBehalf = FALSE, $onBehalfParams = array()) {
203 //Open Live Contribution Page
204 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
205 // Select membership type 1
206 $this->waitForElementPresent("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label");
207 if ($memTypeId != 'No thank you') {
208 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//div/span/label/span[1][contains(text(),'$memTypeId')]");
209 }
210 else {
211 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label[contains(text(),'$memTypeId')]");
212 }
213 if (!$otherAmount && $amountSection) {
214 $this->click("xpath=//div[@class='crm-section contribution_amount-section']/div[2]//span/label[text()='No thank you']");
215 }
216 elseif ($amountSection) {
217 $this->clickAt("xpath=//div[@class='content other_amount-content']/input");
218 $this->keyDown("xpath=//div[@class='content other_amount-content']/input", " ");
219 $this->type("xpath=//div[@class='content other_amount-content']/input", $otherAmount);
220 $this->typeKeys("xpath=//div[@class='content other_amount-content']/input", $otherAmount);
221 }
222 if ($payLater) {
223 $this->waitForAjaxContent();
224 $this->click("xpath=//label[text()='Pay later label {$hash}']");
225 }
226 if ($onBehalf && $onBehalfParams) {
227 if ($onBehalfParams['mode'] == 'optional') {
228 $this->click("is_for_organization");
229 }
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 }
239 $this->type("email-5", $firstName . "@example.com");
240 $this->waitForElementPresent("first_name");
241 $this->type("first_name", $firstName);
242 $this->waitForElementPresent("last_name");
243 $this->type("last_name", $lastName);
244
245 $streetAddress = "100 Main Street";
246 $this->waitForElementPresent("street_address-1");
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");
252
253 if ($freeMembership) {
254 $this->waitForElementPresent("xpath=//div[@id='payment_information'][@style='display: none;']");
255 }
256 else {
257 if (!$payLater && $amountSection) {
258 $this->click("xpath=//label[text()='Test Processor']");
259 $this->waitForAjaxContent();
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 }
278 }
279 $this->click("_qf_Main_upload-bottom");
280 $this->waitForElementPresent("_qf_Confirm_next-bottom");
281
282 $this->click("_qf_Confirm_next-bottom");
283 $this->waitForPageToLoad($this->getTimeoutMsec());
284 }
285
286 public function testOnlineMembershipCreateWithContribution() {
287 //login with admin credentials & make sure we do have required permissions.
288 $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
289 $this->changePermissions($permissions);
290
291 $hash = substr(sha1(rand()), 0, 7);
292 $rand = 2 * rand(2, 50);
293 // Use default payment processor
294 $processorName = 'Test Processor';
295 $amountSection = TRUE;
296 $payLater = TRUE;
297 $allowOtherAmount = TRUE;
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;
309 $isSeparatePayment = FALSE;
310 $membershipsRequired = FALSE;
311 $fixedAmount = FALSE;
312 $contributionTitle = "Title $hash";
313 $pageId = $this->webtestAddContributionPage($hash,
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,
334 $allowOtherAmount,
335 TRUE,
336 'Donation',
337 $fixedAmount,
338 $membershipsRequired
339 );
340 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
341 $lastName = 'An' . substr(sha1(rand()), 0, 7);
342
343 //logout
344 $this->webtestLogout();
345
346 $this->_testOnlineMembershipSignup($pageId, 'No thank you', $firstName, $lastName, FALSE, $hash, 50);
347
348 // Log in using webtestLogin() method
349 $this->webtestLogin();
350
351 //Find Contribution
352 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
353
354 $this->type("sort_name", "$lastName $firstName");
355 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
356 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
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 );
367 foreach ($verifyFinancialData as $col => $data) {
368 $this->verifyText("xpath=//tr[@class='crm-child-row']/td/div/table/tbody/tr[2]/td[{$col}]", $data);
369 }
370 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
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 }
384
385 /**
386 * CRM-16302 - To check whether membership, contribution are
387 * created for free membership signup.
388 */
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);
396 $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = FALSE;
397 $premiums = $widget = $pcp = $isSeparatePayment = $membershipsRequired = $fixedAmount = $friend = FALSE;
398 $memberships = TRUE;
399 $memPriceSetId = NULL;
400 $onBehalf = TRUE;
401 $profilePreId = 1;
402 $profilePostId = NULL;
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);
442
443 $processors = array(
444 'Test Processor',
445 'AuthNet',
446 'PayPal',
447 'PayPal_Standard',
448 );
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");
477 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
478 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
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 );
490 foreach ($verifyFinancialData as $col => $data) {
491 $this->verifyText("xpath=//tr[@class='crm-child-row']/td/div/table/tbody/tr[2]/td[{$col}]", $data);
492 }
493 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
494
495 //View Contribution Record and verify data
496 $expected = array(
497 'From' => "{$firstName} {$lastName}",
498 'Financial Type' => 'Member Dues (test) ',
499 'Total Amount' => '0.00',
500 'Contribution Status' => 'Completed',
501 'Source' => "Online Contribution: $contributionTitle",
502 'Online Contribution Page' => $contributionTitle,
503 );
504 $this->webtestVerifyTabularData($expected);
505
506 //Find Member
507 $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
508 $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
509
510 $this->type("sort_name", "$lastName $firstName");
511 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
512 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='View']");
513 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
514
515 //View Membership Record
516 $verifyData = array(
517 'Member' => $firstName . ' ' . $lastName,
518 'Membership Type' => $memTypeTitle,
519 'Source' => 'Online Contribution:' . ' ' . $contributionTitle,
520 'Status' => 'New',
521 );
522
523 $this->webtestVerifyTabularData($verifyData);
524 }
525 }
526
527 /**
528 * CRM-18163 - To check whether multiple organizations with same name
529 * are created based on dedupe rule other than org name.
530 */
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');
538
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;
561 $profilePostId = NULL;
562 $onBehalf = 'optional';
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
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);
607
608 $onBehalfParams = array(
609 'org_name' => 'Test Org Dedupe', // Same Org Name.
610 'org_phone' => '123-456-789',
611 'org_email' => 'testorgdedupe@test.com', // Same Email address.
612 'org_postal_code' => 'ABC 123',
613 'mode' => 'optional',
614 );
615
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);
619
620 $this->webtestLogin();
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");
627 }
628
629 }