Fix phone_type_id in export per test
authoreileen <emcnaughton@wikimedia.org>
Thu, 13 Dec 2018 21:48:22 +0000 (10:48 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 14 Dec 2018 03:50:25 +0000 (16:50 +1300)
CRM/Export/BAO/ExportProcessor.php
tests/phpunit/CRM/Export/BAO/ExportTest.php

index 7b1f8cf3bcd925fc3c8dcb813a226006b82cacf0..6663265ab835ec01e7a76486f85b6dd6ca6d788b 100644 (file)
@@ -718,6 +718,9 @@ class CRM_Export_BAO_ExportProcessor {
                 return $i18n->crm_translate($fieldValue, $metadata[$field]);
               }
               if (!empty($metadata[$field]['pseudoconstant'])) {
+                if (!empty($metadata[$field]['bao'])) {
+                  return CRM_Core_PseudoConstant::getLabel($metadata[$field]['bao'], $metadata[$field]['name'], $fieldValue);
+                }
                 // This is not our normal syntax for pseudoconstants but I am a bit loath to
                 // call an external function until sure it is not increasing php processing given this
                 // may be iterated 100,000 times & we already have the $imProvider var loaded.
@@ -1147,7 +1150,7 @@ class CRM_Export_BAO_ExportProcessor {
    * @return string
    */
   protected function getOutputSpecificationIndex($key, $relationshipType, $locationType, $entityLabel) {
-    if ($locationType || $entityLabel || $key === 'im') {
+    if ($entityLabel || $key === 'im') {
       // Just cos that's the history...
       if ($key !== 'master_id') {
         $key = $this->getHeaderForRow($key);
@@ -1200,8 +1203,9 @@ class CRM_Export_BAO_ExportProcessor {
    * @return string
    */
   protected function getOutputSpecificationFieldKey($key, $relationshipType, $locationType, $entityLabel) {
-    if ($relationshipType || $entityLabel || $key === 'im') {
+    if ($entityLabel || $key === 'im') {
       if ($key !== 'state_province' && $key !== 'id') {
+        // @todo - test removing this - indexing by $key should be fine...
         $key = $this->getHeaderForRow($key);
       }
     }
index ef7af5c03e8b09fa6b72101f39245c122880d4a0..626af0a40b506a4c67423542bd74bf0594124345 100644 (file)
@@ -833,14 +833,14 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
         'contact_id' => $contactID,
         'location_type_id' => 'Billing',
         'phone_type_id' => 'Mobile',
-        'phone' =>  'Billing' . 'Mobile' . $contactID,
+        'phone' => 'Billing' . 'Mobile' . $contactID,
         'is_primary' => 1,
       ]);
       $this->callAPISuccess('Phone', 'create', [
         'contact_id' => $contactID,
         'location_type_id' => 'Home',
         'phone_type_id' => 'Phone',
-        'phone' =>  'Home' . 'Phone' . $contactID,
+        'phone' => 'Home' . 'Phone' . $contactID,
       ]);
     }