Skip to content

Commit

Permalink
Merge pull request #15443 from eileenmcnaughton/ex_merge
Browse files Browse the repository at this point in the history
dev/core#1302 fix regression on exported when merging addresses with specified fields
  • Loading branch information
seamuslee001 authored Oct 8, 2019
2 parents d375fc0 + 15d60ff commit b4c078b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CRM/Export/BAO/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public static function exportComponents(

if ($processor->isMergeSameAddress()) {
foreach (array_keys($processor->getAdditionalFieldsForSameAddressMerge()) as $field) {
if ($field === 'id') {
$field = 'civicrm_primary_id';
}
$processor->setColumnAsCalculationOnly($field);
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/phpunit/CRM/Export/BAO/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,17 @@ public function testExportMasterAddress() {
$this->assertEquals(CRM_Contact_BAO_Contact::getMasterDisplayName($this->masterAddressID), $row['Home-Master Address Belongs To']);
}

/**
* Test merging same address when specifying fields.
*
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
public function testMergeSameAddressSpecifyFields() {
$this->setUpContactSameAddressExportData();
$this->doExportTest(['mergeSameAddress' => TRUE, 'fields' => [['contact_type' => 'Individual', 'name' => 'master_id', 'location_type_id' => 1]]]);
}

/**
* Test the merge same address option.
*
Expand Down

0 comments on commit b4c078b

Please sign in to comment.