Eileen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395858 )

Change subject: Allow Organization merge to resolve casing on organization_name
......................................................................

Allow Organization merge to resolve casing on organization_name

Bug: T18108
Change-Id: I31f9cd0cb539f7e9dcbd2f1921906a9d7ca6d5a5
---
M sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 26 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/58/395858/1

diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
index e5eb6cb..7a0051c 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
@@ -915,6 +915,31 @@
   }
 
   /**
+   * Test that a conflict on casing in first names is handled for 
organization_name.
+   */
+  public function testBatchMergeConflictNameCasingOrgs() {
+    $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', array(
+      'contact_type' => 'Organization',
+      'used' => 'Unsupervised',
+      'return' => 'id',
+      'options' => array('limit' => 1),
+    ));
+
+    // Do a pre-merge to get us to a known 'no mergeable contacts' state.
+    $this->callAPISuccess('Job', 'process_batch_merge', array('mode' => 
'safe', 'rule_group_id' => $rule_group_id));
+
+    $org1 = $this->callAPISuccess('Contact', 'create', 
array('organization_name' => 'donald duck', 'contact_type' => 'Organization'));
+    $org2 = $this->callAPISuccess('Contact', 'create', 
array('organization_name' => 'Donald Duck', 'contact_type' => 'Organization'));
+
+    $result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe', 'rule_group_id' => $rule_group_id));
+    $this->assertEquals(0, count($result['values']['skipped']));
+    $this->assertEquals(1, count($result['values']['merged']));
+
+    $contact = $this->callAPISuccess('Contact', 'get', array('id' => 
$org1['id'], 'sequential' => 1));
+    $this->assertEquals('Donald Duck', 
$contact['values'][0]['organization_name']);
+  }
+
+  /**
    * Make sure José whomps Jose.
    *
    * Test diacritic matches are resolved to the one using 'authentic' 
characters.
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index d1c525d..1ad487d 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -2543,7 +2543,7 @@
  * @return bool
  */
 function _wmf_civicrm_merge_resolve_casing_conflict($fieldName, 
&$moveFieldValue, &$valueToKeep, &$valueToOverwrite) {
-  $fieldsToResolveCasingFor = array('last_name', 'first_name');
+  $fieldsToResolveCasingFor = array('last_name', 'first_name', 
'organization_name');
   if (!in_array(str_replace('move_', '', $fieldName), 
$fieldsToResolveCasingFor)) {
     return FALSE;
   }

-- 
To view, visit https://gerrit.wikimedia.org/r/395858
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I31f9cd0cb539f7e9dcbd2f1921906a9d7ca6d5a5
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to