Skip to content
Snippets Groups Projects
Commit 2890c0f9 authored by ayduns's avatar ayduns
Browse files

Set a default location in Email.create API call. Add test for this.

Default location used to create the email is the default LocationType
parent 55d2ecea
Branches
Tags
No related merge requests found
......@@ -57,6 +57,10 @@ function _civicrm_api3_email_create_spec(&$params) {
$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;
}
}
/**
......
......@@ -78,6 +78,20 @@ class api_v3_EmailTest extends CiviUnitTestCase {
$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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment