CRM-19035 update tests to reflect consist use of entity1 for dstID
authoreileen <emcnaughton@wikimedia.org>
Tue, 12 Jul 2016 06:51:18 +0000 (18:51 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 12 Jul 2016 06:51:18 +0000 (18:51 +1200)
Since we should always see the lower id in dstID now and that should always map to entity1
the tests need updating

CRM/Dedupe/BAO/RuleGroup.php
tests/phpunit/CRM/Core/BAO/PrevNextCacheTest.php
tests/phpunit/CRM/Dedupe/MergerTest.php

index a6ea3542fcd86b6ddca962c7d46d61926ddadac3..1e156066ed5fba1456cdb18eb727e61ca8265021 100644 (file)
@@ -378,7 +378,8 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
         list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(array('c1', 'c2'));
         $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
       }
-      $query = "SELECT dedupe.id1, dedupe.id2, dedupe.weight
+      $query = "SELECT IF(dedupe.id1 < dedupe.id2, dedupe.id1, dedupe.id2) as id1,
+                IF(dedupe.id1 < dedupe.id2, dedupe.id2, dedupe.id1) as id2, dedupe.weight
                 FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id
                             JOIN civicrm_contact c2 ON dedupe.id2 = c2.id {$this->_aclFrom}
                        LEFT JOIN civicrm_dedupe_exception exc ON dedupe.id1 = exc.contact_id1 AND dedupe.id2 = exc.contact_id2
index 4883618798b428d95da9f7931e9bc9e8d1fa1949..4d177bf660a1d7d5f42e09419c64ff8d1af3ddb8 100644 (file)
@@ -48,8 +48,8 @@ class CRM_Core_BAO_PrevNextCacheTest extends CiviUnitTestCase {
     $dao->id = 1;
     CRM_Core_BAO_PrevNextCache::flipPair(array(1), 0);
     $dao->find(TRUE);
-    $this->assertEquals(2, $dao->entity_id1);
-    $this->assertEquals(1, $dao->entity_id2);
+    $this->assertEquals(1, $dao->entity_id1);
+    $this->assertEquals(2, $dao->entity_id2);
     $this->assertEquals(serialize(array(
       'srcName' => 'Mr. Maurice Mouse II',
       'dstID' => 1,
index 1faee3cb2f859527e2a7a2e2392284487668f6b9..c9cc7c67fcb27cdce5645f5c6372489ec9795a7f 100644 (file)
@@ -284,17 +284,17 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
 
     $this->assertEquals(array(
       0 => array(
-        'srcID' => $this->contacts[0]['id'],
+        'srcID' => $this->contacts[1]['id'],
         'srcName' => 'Mr. Mickey Mouse II',
-        'dstID' => $this->contacts[1]['id'],
+        'dstID' => $this->contacts[0]['id'],
         'dstName' => 'Mr. Mickey Mouse II',
         'weight' => 20,
         'canMerge' => TRUE,
       ),
       1 => array(
-        'srcID' => $this->contacts[2]['id'],
+        'srcID' => $this->contacts[3]['id'],
         'srcName' => 'Mr. Minnie Mouse II',
-        'dstID' => $this->contacts[3]['id'],
+        'dstID' => $this->contacts[2]['id'],
         'dstName' => 'Mr. Minnie Mouse II',
         'weight' => 20,
         'canMerge' => TRUE,