$params['is_primary']['api.default'] = 0;
$params['email']['api.required'] = 1;
$params['contact_id']['api.required'] = 1;
+ $defaultLocation = CRM_Core_BAO_LocationType::getDefault();
+ if ($defaultLocation) {
+ $params['location_type_id']['api.default'] = $defaultLocation->id;
+ }
}
/**
$delresult = $this->callAPISuccess('email', 'delete', array('id' => $result['id']));
}
+ /**
+ * If no location is specified when creating a new email, it should default to
+ * the LocationType default
+ *
+ * Only API v3
+ */
+ public function testCreateEmailDefaultLocation() {
+ $params = $this->_params;
+ unset($params['location_type_id']);
+ $result = $this->callAPIAndDocument('email', 'create', $params, __FUNCTION__, __FILE__);
+ $this->assertEquals(CRM_Core_BAO_LocationType::getDefault()->id, $result['values'][$result['id']]['location_type_id']);
+ $delresult = $this->callAPISuccess('email', 'delete', array('id' => $result['id']));
+ }
+
/**
* If a new email is set to is_primary the prev should no longer be.
*