From 144d0efe60136a6f4ec335dbd535b071505e5c33 Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Mon, 27 Feb 2017 16:13:50 +0000 Subject: [PATCH] Fix CRM-15505: Make state_province_name return the full name of the state, not the abbreviation --- CRM/Contact/BAO/Query.php | 2 +- .../CRM/Contact/BAO/QueryStateNameTest.php | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index e905154411..009b991866 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5851,7 +5851,7 @@ AND displayRelType.is_active = 1 $dao->$idColumn = $val; if ($key == 'state_province_name') { - $dao->{$value['pseudoField']} = $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); + $dao->{$value['pseudoField']} = $dao->$key = CRM_Core_PseudoConstant::stateProvince($val); } else { $dao->{$value['pseudoField']} = $dao->$key = CRM_Core_PseudoConstant::getLabel($baoName, $value['pseudoField'], $val); diff --git a/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php b/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php new file mode 100644 index 0000000000..cba30153dc --- /dev/null +++ b/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php @@ -0,0 +1,37 @@ + 'Individual', + 'first_name' => 'John', + 'last_name' => 'Doe', + 'api.Address.create' => array( + 'location_type_id' => 'Home', + 'state_province_id' => $state_name, + ), + ); + $create_res = civicrm_api3('Contact', 'Create', $create_params); + + $get_params = array( + 'id' => $create_res['id'], + 'sequential' => 1, + ); + $get_res = civicrm_api3('Contact', 'get', $get_params); + + $this->assertEquals($state_name, $get_res['values'][0]['state_province_name']); + } + +} -- 2.25.1