Customvalue ID is ignored
authordeb.monish <monish.deb@jmaconsulting.biz>
Tue, 31 Jul 2018 19:47:10 +0000 (01:17 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Tue, 31 Jul 2018 19:51:21 +0000 (01:21 +0530)
CRM/Core/BAO/CustomValueTable.php
tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php

index 9455b06a4fa3cabc91315e1f4e16d0858aabd5d6..73a431065a898d73f8c5e80fee96c2db3ba9996d 100644 (file)
@@ -637,6 +637,10 @@ AND    cf.id IN ( $fieldIDList )
           'extends' => $dao->extends,
         );
 
+        if (!empty($params['id'])) {
+          $cvParam['id'] = $params['id'];
+        }
+
         if ($cvParam['type'] == 'File') {
           $cvParam['file_id'] = $fieldValue['value'];
         }
index 8d7255a5bd31c077755741a9eb265f34bc9faeaa..ad6e0d86bdc6c9267761289d7ebd8fc42a3e9cdd 100644 (file)
@@ -35,6 +35,20 @@ class CRM_Core_BAO_CustomValueTableMultipleTest extends CiviUnitTestCase {
     $this->assertEquals($params["custom_{$customField['id']}_-1"], $result["custom_{$customField['id']}_1"]);
     $this->assertEquals($params['entityID'], $result['entityID']);
 
+    $updateParams = array(
+      'id' => 1,
+      'entityID' => $contactID,
+      "custom_{$customField['id']}" => 2,
+    );
+    CRM_Core_BAO_CustomValueTable::setValues($updateParams);
+
+    $criteria = array(
+      'id' => 1,
+      'entityID' => $contactID,
+    );
+    $result = CRM_Core_BAO_CustomValueTable::getValues($criteria);
+    $this->assertEquals(2, $result["custom_{$customField['id']}_1"]);
+
     $this->customFieldDelete($customField['id']);
     $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactID);