Add unit test for handling of 'special values' when retrieving merge data
authoreileenmcnaugton <emcnaughton@wikimedia.org>
Thu, 16 May 2019 04:48:00 +0000 (16:48 +1200)
committerEileen McNaughton <eileenmcnaughton@Eileens-MacBook-Pro.local>
Fri, 17 May 2019 23:29:07 +0000 (11:29 +1200)
This is preliminary to a code cleanup.

m

tests/phpunit/CRM/Dedupe/MergerTest.php

index 96f440873f980496c62fc6eaf0cdf8823f637c15..d065d0ef838b56785f0bb72b8b959ba4b629fd80 100644 (file)
@@ -485,6 +485,26 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
     ), $pairs);
   }
 
+  /**
+   * Test the special info handling is unchanged after cleanup.
+   *
+   * Note the handling is silly - we are testing to lock in over short term changes not to imply any contract on the
+   * function.
+   */
+  public function testgetRowsElementsAndInfoSpecialInfo() {
+    $contact1 = $this->individualCreate(['preferred_communication_method' => [], 'communication_style_id' => 'Familiar', 'prefix_id' => 'Mrs.', 'suffix_id' => 'III']);
+    $contact2 = $this->individualCreate(['preferred_communication_method' => ['SMS', 'Fax'], 'communication_style_id' => 'Formal', 'gender_id' => 'Female']);
+    $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($contact1, $contact2);
+    $rows = $rowsElementsAndInfo['rows'];
+    $this->assertEquals(['main' => 'Mrs.', 'other' => 'Mr.', 'title' => 'Individual Prefix'], $rows['move_prefix_id']);
+    $this->assertEquals(['main' => 'III', 'other' => 'II', 'title' => 'Individual Suffix'], $rows['move_suffix_id']);
+    $this->assertEquals(['main' => '', 'other' => 'Female', 'title' => 'Gender'], $rows['move_gender_id']);
+    $this->assertEquals(['main' => 'Familiar', 'other' => 'Formal', 'title' => 'Communication Style'], $rows['move_communication_style_id']);
+    $this->assertEquals(1, $rowsElementsAndInfo['migration_info']['move_communication_style_id']);
+    $this->assertEquals(['main' => '', 'other' => 'SMS, Fax', 'title' => 'Preferred Communication Method'], $rows['move_preferred_communication_method']);
+    $this->assertEquals('\ 14\ 15\ 1', $rowsElementsAndInfo['migration_info']['move_preferred_communication_method']);
+  }
+
   /**
    * Test migration of Membership.
    */