CRM-17563: Dedupe rules - changes not saved when editing existing rule
authoryashodha <yashodha.chaku@webaccessglobal.com>
Mon, 16 Nov 2015 12:45:05 +0000 (18:15 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Mon, 16 Nov 2015 12:45:05 +0000 (18:15 +0530)
----------------------------------------
* CRM-17563: Dedupe rules - changes not saved when editing existing rule
  https://issues.civicrm.org/jira/browse/CRM-17563

CRM/Contact/Form/DedupeRules.php
tests/phpunit/WebTest/Contact/DupeContactTest.php

index a81fb5312903098b09060eeb5e9379044d7fabb0..bb4e553c8283640319f7c8bd5dbe07909626d556 100644 (file)
@@ -228,7 +228,7 @@ UPDATE civicrm_dedupe_rule_group
     }
 
     // lets skip updating of fields for reserved dedupe group
-    if (isset($this->_defaults['is_reserved'])) {
+    if (CRM_Utils_Array::value('is_reserved', $this->_defaults)) {
       CRM_Core_Session::setStatus(ts("The rule '%1' has been saved.", array(1 => $rgDao->title)), ts('Saved'), 'success');
       return;
     }
index 3b9d426c4de800bc4b8d4025440089e0f3a10a82..e126e9a82b28494e85e0be344b25a8e77983474b 100644 (file)
@@ -88,4 +88,67 @@ class WebTest_Contact_DupeContactTest extends CiviSeleniumTestCase {
     $this->assertElementContainsText("css=.notify-content", "Please correct the following errors in the form fields below: One matching contact was found. You can View or Edit the existing contact.");
   }
 
+  /**
+   *Edit Dedupe rule for individual
+   */
+  public function testEditRule() {
+    $this->webtestLogin();
+    $this->openCiviPage('contact/deduperules', 'action=add&contact_type=Individual&reset=1');
+    $ruleName = 'Rule_' . substr(sha1(rand()), 0, 7);
+
+    //Add Rule for individual
+    $this->type("title", "$ruleName");
+    $this->click("xpath=//table[@class='form-layout']/tbody/tr[@class='crm-dedupe-rules-form-block-used']/td[2]/label[text()='General']");
+
+    // Add first name
+    $this->select("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[1]/select", 'label=First Name');
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input", 10);
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input", 10);
+    // Add last name
+    $this->select("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[1]/select", 'label=Last Name');
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input", 10);
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[3]/input", 10);
+    // Add email
+    $this->select("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[1]/select", 'label=Email');
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input", 10);
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[3]/input", 10);
+    $this->click("_qf_DedupeRules_next-bottom");
+    $this->waitForText("crm-notification-container", "The rule '$ruleName' has been saved.");
+
+    // Edit the rule for individual.
+    $this->click("xpath=//div[@id='browseValues_Individual']/div[1]/div/table/tbody//tr/td[1][text()='$ruleName']/../td[3]/span//a[text()='Edit Rule']");
+    $this->waitForElementPresent("_qf_DedupeRules_cancel-bottom");
+
+    //edit length and weight for First Name
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input", 7);
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input", 5);
+
+    //edit length and weight for Last Name
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input", 7);
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[3]/input", 8);
+
+    //edit length and weight for Email
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input", 20);
+    $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[3]/input", 10);
+
+    $this->click("_qf_DedupeRules_next-bottom");
+    $this->waitForAjaxContent();
+    $this->click("xpath=//div[@id='browseValues_Individual']/div[1]/div/table/tbody//tr/td[1][text()='$ruleName']/../td[3]/span//a[text()='Edit Rule']");
+    $this->waitForAjaxContent();
+
+    $lengthValueFname = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input@value");
+    $weighthValueFname = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input@value");
+    $lengthValueLname = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input@value");
+    $lengthValueLname = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[3]/input@value");
+    $lengthValueEmail = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input@value");
+    $weighthValueEmail = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[3]/input@value");
+
+    $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input[@value=$lengthValueFname]"));
+    $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input[@value=$weighthValueFname]"));
+    $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input[@value=$lengthValueLname]"));
+    $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input[@value=$lengthValueLname]"));
+    $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input[@value=$lengthValueEmail]"));
+    $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input[@value=$weighthValueEmail]"));
+  }
+
 }