CRM-18163 CIVI-3 Added webtest for dedupe org on postal code when onbehalf contributi...
authorEdsel <edsel.lopez@jmaconsulting.biz>
Wed, 9 Mar 2016 14:10:14 +0000 (19:40 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Wed, 9 Mar 2016 14:10:14 +0000 (19:40 +0530)
----------------------------------------
* CRM-18163: Unsupervised Organization Rule for On Behalf Of Contributions
  https://issues.civicrm.org/jira/browse/CRM-18163

tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Member/OnlineMembershipCreateTest.php

index 10fc2ca0442215f61463c7a64d9c7830c69ec9a8..502266c5d48bbc00b1046da222b00e33d80797d2 100644 (file)
@@ -1223,7 +1223,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     if ($memPriceSetId || (($membershipTypes === TRUE) || (is_array($membershipTypes) && !empty($membershipTypes)))) {
       // go to step 3 (memberships)
       $this->click('link=Memberships');
-      $this->waitForElementPresent('_qf_MembershipBlock_next-bottom');
+      $this->waitForElementPresent('_qf_MembershipBlock_submit_savenext');
 
       // fill in step 3 (Memberships)
       $this->click('member_is_active');
index 5a215e94ccf929b3af352be774231cd69b31a3f4..bc20bc9dd92af02fd63ac8b0688a3b1bd0940ef2 100644 (file)
@@ -199,7 +199,7 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
    * @param bool $amountSection
    * @param bool $freeMembership
    */
-  public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE) {
+  public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE, $onBehalf = FALSE, $onBehalfParams = array()) {
     //Open Live Contribution Page
     $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
     // Select membership type 1
@@ -207,10 +207,8 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
     if ($memTypeId != 'No thank you') {
       $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//div/span/label/span[1][contains(text(),'$memTypeId')]");
     }
-
     else {
       $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label[contains(text(),'$memTypeId')]");
-
     }
     if (!$otherAmount && $amountSection) {
       $this->click("xpath=//div[@class='crm-section contribution_amount-section']/div[2]//span/label[text()='No thank you']");
@@ -225,6 +223,16 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
       $this->waitForAjaxContent();
       $this->click("xpath=//label[text()='Pay later label {$hash}']");
     }
+    if ($onBehalf && $onBehalfParams) {
+      $this->type("onbehalf[organization_name]", $onBehalfParams['org_name']);
+      $this->type("onbehalf[phone-3-1]", $onBehalfParams['org_phone']);
+      $this->type("onbehalf[email-3]", $onBehalfParams['org_email']);
+      $this->type("onbehalf[street_address-3]", "100 Main Street");
+      $this->type("onbehalf[city-3]", "San Francisco");
+      $this->type("onbehalf[postal_code-3]", $onBehalfParams['org_postal_code']);
+      $this->select("onbehalf[country-3]", "value=1228");
+      $this->select("onbehalf[state_province-3]", "value=1001");
+    }
     $this->type("email-5", $firstName . "@example.com");
     $this->waitForElementPresent("first_name");
     $this->type("first_name", $firstName);
@@ -382,10 +390,11 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
 
     $hash = substr(sha1(rand()), 0, 7);
     $rand = 2 * rand(2, 50);
-    $amountSection = $payLater = $allowOtherAmount = $onBehalf = $pledges = $recurring = FALSE;
+    $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = FALSE;
     $premiums = $widget = $pcp = $isSeparatePayment = $membershipsRequired = $fixedAmount = $friend = FALSE;
     $memberships = TRUE;
     $memPriceSetId = NULL;
+    $onBehalf = TRUE;
     $profilePreId = 1;
     $profilePostId = NULL;
     $contributionTitle = "Title $hash";
@@ -512,4 +521,97 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
     }
   }
 
+  public function testOnlineMembershipCreateOnBehalfWithOrgDedupe() {
+    // Add unsupervised dedupe rule.
+    $this->webtestLogin();
+    $this->openCiviPage("contact/deduperules", "reset=1");
+    $this->waitForElementPresent("xpath=//div[@id='option13_wrapper']/table/tbody/tr[2]/td[3]/span/a[2][text()='Edit Rule']");
+    $this->click("xpath=//div[@id='option13_wrapper']/table/tbody/tr[2]/td[3]/span/a[2][text()='Edit Rule']");
+    $this->waitForElementPresent('_qf_DedupeRules_next');
+    
+    $this->type('title', "Postal Code unsupervised dedupe rule");
+    $this->click('CIVICRM_QFID_Unsupervised_used');
+    $this->select('where_0', "Organization Name");
+    $this->type('weight_0', 10);
+    $this->select('where_1', "Postal Code");
+    $this->type('length_1', 3);
+    $this->type('weight_1', 10);
+    $this->type('threshold', 20);
+    $this->click('_qf_DedupeRules_next');
+    $this->webtestLogout();
+
+    //login with admin credentials & make sure we do have required permissions.
+    $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
+    $this->changePermissions($permissions);
+
+    $hash = substr(sha1(rand()), 0, 7);
+    $rand = 2 * rand(2, 50);
+    $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = $membershipsRequired = FALSE;
+    $premiums = $widget = $pcp = $isSeparatePayment = $fixedAmount = $friend = FALSE;
+    $memberships = FALSE;
+    $memPriceSetId = NULL;
+    $profilePreId = 1;
+    $profilePostId = NULL; 
+    $onBehalf = TRUE;
+    $contributionTitle = "Title $hash";
+    $pageId = $this->webtestAddContributionPage(
+      $hash,
+      $rand,
+      $contributionTitle,
+      NULL,
+      $amountSection,
+      $payLater,
+      $onBehalf,
+      $pledges,
+      $recurring,
+      $memberships,
+      $memPriceSetId,
+      $friend,
+      $profilePreId,
+      $profilePostId,
+      $premiums,
+      $widget,
+      $pcp,
+      FALSE,
+      FALSE,
+      $isSeparatePayment,
+      FALSE,
+      $allowOtherAmount,
+      TRUE,
+      'Member Dues',
+      $fixedAmount,
+      $membershipsRequired
+    );
+    $memTypeParams = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 0);
+    $memTypeTitle = $memTypeParams['membership_type'];
+    $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle}']/../../td[12]/span/a[3]@href"));
+    $memTypeId = $memTypeId[1];
+
+    // edit contribution page amounts tab to uncheck real time monetary transaction
+    $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_submit_savenext');
+    $this->click('member_is_active');
+    $this->waitForElementPresent('displayFee');
+    $this->type('new_title', "Title - New Membership $hash");
+    $this->type('renewal_title', "Title - Renewals $hash");
+    $this->click("membership_type_$memTypeId");
+    $this->clickLink('_qf_MembershipBlock_submit_savenext');
+
+    $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
+    $lastName = 'An' . substr(sha1(rand()), 0, 7);
+    
+    $onBehalfParams = array(
+      'org_name' => 'Test Org',
+      'org_phone' => '123-456-789',
+      'org_email' => 'testorg@test.com',
+      'org_postal_code' => 'ABC 123',
+    );
+    
+    $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE, TRUE, $onBehalfParams);
+    $onBehalfParams['org_postal_code'] = 'XYZ 123';
+    $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE, TRUE, $onBehalfParams);
+    
+    // Log in using webtestLogin() method
+    $this->webtestLogin();
+  }
+
 }