From 0608e1e0a2f1cedab2fe9e1c2a75fd7d97a70674 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Thu, 16 May 2019 16:48:00 +1200 Subject: [PATCH] Add unit test for handling of 'special values' when retrieving merge data This is preliminary to a code cleanup. m --- tests/phpunit/CRM/Dedupe/MergerTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index 96f440873f..d065d0ef83 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -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('45', $rowsElementsAndInfo['migration_info']['move_preferred_communication_method']); + } + /** * Test migration of Membership. */ -- 2.25.1