switch ($fieldName) {
// Filter state_province list based on chosen country or site defaults
case 'state_province_id':
+ case 'state_province_name':
+ case 'state_province':
+ // change $fieldName to DB specific names.
+ $fieldName = 'state_province_id';
if (empty($props['country_id'])) {
$config = CRM_Core_Config::singleton();
if (!empty($config->provinceLimit)) {
// Filter country list based on site defaults
case 'country_id':
+ case 'country':
+ // change $fieldName to DB specific names.
+ $fieldName = 'country_id';
if ($context != 'get' && $context != 'validate') {
$config = CRM_Core_Config::singleton();
if (!empty($config->countryLimit) && is_array($config->countryLimit)) {
$this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']);
}
+ /**
+ * Test Address parameters
+ *
+ * This include state_province, state_province_name, country
+ */
+ public function testContactGetWithAddressFields() {
+ $individuals = array(
+ array(
+ 'first_name' => 'abc1',
+ 'contact_type' => 'Individual',
+ 'last_name' => 'xyz1',
+ 'api.address.create' => array(
+ 'country' => 'United States',
+ 'state_province_id' => 'Michigan',
+ 'location_type_id' => 1,
+ ),
+ ),
+ array(
+ 'first_name' => 'abc2',
+ 'contact_type' => 'Individual',
+ 'last_name' => 'xyz2',
+ 'api.address.create' => array(
+ 'country' => 'United States',
+ 'state_province_id' => 'Alabama',
+ 'location_type_id' => 1,
+ ),
+ ),
+ );
+ foreach ($individuals as $params) {
+ $contact = $this->callAPISuccess('contact', 'create', $params);
+ }
+
+ // Check whether Contact get API return successfully with below Address params.
+ $fieldsToTest = array(
+ 'state_province_name' => 'Michigan',
+ 'state_province' => 'Michigan',
+ 'country' => 'United States',
+ 'state_province_name' => array('IN' => array('Michigan', 'Alabama')),
+ 'state_province' => array('IN' => array('Michigan', 'Alabama')),
+ );
+ foreach ($fieldsToTest as $field => $value) {
+ $getParams = array(
+ 'id' => $contact['id'],
+ $field => $value,
+ );
+ $this->callAPISuccess('Contact', 'get', $getParams);
+ }
+ }
+
/**
* Test Deceased date parameters.
*