From 808a80ba8ffa53472245c671016adfba9624f93c Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 23 Aug 2019 19:26:17 +1200 Subject: [PATCH] Fix export header for 'Contact ID' Fixes 1) the contact id field is exported with the heading 'contact_id' - should be 'Contact ID' 2) code quality issue - we should have metadata defined for all fields but it is missing for a few (now one less) --- CRM/Export/BAO/ExportProcessor.php | 1 + tests/phpunit/CRM/Export/BAO/ExportTest.php | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index bd9559bbe2..4405a1aaee 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -602,6 +602,7 @@ class CRM_Export_BAO_ExportProcessor { $queryFields['country']['context'] = 'country'; $queryFields['world_region']['context'] = 'country'; $queryFields['state_province']['context'] = 'province'; + $queryFields['contact_id'] = ['title' => ts('Contact ID'), 'type' => CRM_Utils_Type::T_INT]; $this->queryFields = $queryFields; } diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 71f8d5b068..399aca1a8f 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -780,7 +780,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $this->doExportTest(['fields' => $mappedFields, 'ids' => [$this->contactIDs[0]]]); foreach ($this->csv->getRecords() as $row) { - $id = $row['contact_id']; + $id = $row['Contact ID']; $this->assertEquals('AIM', $row['Billing-IM Provider']); $this->assertEquals('AIM', $row['Whare Kai-IM Provider']); $this->assertEquals('BillingJabber' . $id, $row['Billing-IM Screen Name-Jabber']); @@ -955,17 +955,18 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $this->doExportTest(['fields' => $fields]); foreach ($this->csv as $row) { - $this->assertEquals('Méin' . $row['contact_id'] . 'city', $row['Main-City']); - $this->assertEquals('Billing' . $row['contact_id'] . 'street_address', $row['Billing-Street Address']); - $this->assertEquals('Whare Kai' . $row['contact_id'] . 'postal_code', $row['Whare Kai-Postal Code']); + $contactID = (int) $row['Contact ID']; + $this->assertEquals('Méin' . $contactID . 'city', $row['Main-City']); + $this->assertEquals('Billing' . $contactID . 'street_address', $row['Billing-Street Address']); + $this->assertEquals('Whare Kai' . $contactID . 'postal_code', $row['Whare Kai-Postal Code']); foreach ($relationships as $relatedContactID => $relationship) { - $value = ((int) $row['contact_id'] === $this->contactIDs[0]) ? 'Méin' . $relatedContactID . 'city' : ''; + $value = ($contactID === $this->contactIDs[0]) ? 'Méin' . $relatedContactID . 'city' : ''; $this->assertEquals($value, $row[$relationship['label'] . '-Main-City'], 'checking ' . $relationship['label'] . '-Main-City'); } } $this->assertEquals([ - 'contact_id' => 'contact_id varchar(255)', + 'contact_id' => 'contact_id varchar(16)', 'billing_city' => 'billing_city varchar(64)', 'billing_street_address' => 'billing_street_address varchar(96)', 'billing_postal_code' => 'billing_postal_code varchar(64)', @@ -2217,7 +2218,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { */ protected function getCaseHeaderDefinition() { return [ - 81 => 'contact_id', + 81 => 'Contact ID', 82 => 'Case ID', 83 => 'case_activity_subject', 84 => 'Case Subject', @@ -2489,7 +2490,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'case_activity_medium_id' => 'case_activity_medium_id varchar(255)', 'case_activity_details' => 'case_activity_details text', 'case_activity_is_auto' => 'case_activity_is_auto text', - 'contact_id' => 'contact_id varchar(255)', + 'contact_id' => 'contact_id varchar(16)', 'case_id' => 'case_id varchar(16)', 'case_activity_subject' => 'case_activity_subject text', 'case_status' => 'case_status text', -- 2.25.1