From cab1863a84906380ec67f91ee21ae0a14fa2400a Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 1 Aug 2019 16:03:03 +1000 Subject: [PATCH] Fix handling of location type in Reports --- CRM/Report/Form.php | 2 +- .../CRM/Report/Form/ContactSummaryTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 73c4f561f1..5affd4b5a8 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -5777,7 +5777,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 'options' => CRM_Core_PseudoConstant::country(), ], $options['prefix'] . 'location_type_id' => [ - 'name' => 'is_primary', + 'name' => 'location_type_id', 'title' => $options['prefix_label'] . ts('Location Type'), 'type' => CRM_Utils_Type::T_INT, 'is_fields' => TRUE, diff --git a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php index b173d4d462..dbfb3ed6cb 100644 --- a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php +++ b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php @@ -196,4 +196,36 @@ class CRM_Report_Form_ContactSummaryTest extends CiviReportTestCase { } } + /** + * Test that Loation Type prints out a sensible piece of data + */ + public function testLocationTypeIdHandling() { + $customLocationType = $this->callAPISuccess('LocationType', 'create', [ + 'name' => 'Custom Location Type', + 'display_name' => 'CiviTest Custom Location Type', + 'is_active' => 1, + ]); + $this->individualCreate([ + 'api.Address.create' => [ + 'location_type_id' => $customLocationType['id'], + 'is_primary' => 1, + 'street_number' => 3, + ], + ]); + $input = [ + 'fields' => [ + 'address_street_number', + 'address_odd_street_number', + 'address_location_type_id', + ], + ]; + $obj = $this->getReportObject('CRM_Report_Form_Contact_Summary', $input); + $obj->setParams($obj->getParams()); + $sql = $obj->buildQuery(TRUE); + $rows = []; + $obj->buildRows($sql, $rows); + $obj->formatDisplay($rows); + $this->assertEquals('CiviTest Custom Location Type', $rows[0]['civicrm_address_address_location_type_id']); + } + } -- 2.25.1