_civicrm_api3_api_match_pseudoconstant($params, $entity, $fieldName, $fieldInfo);
}
- // After swapping options, ensure we have an integer
- if (!is_numeric($params[$fieldName]) || (int) $params[$fieldName] != $params[$fieldName]) {
- throw new API_Exception("$fieldname is not a valid integer", 2001, array('error_field' => $fieldname,"type" => "integer"));
+ // After swapping options, ensure we have an integer(s)
+ foreach ((array) ($params[$fieldName]) as $value) {
+ if (!is_numeric($value) || (int) $value != $value) {
+ throw new API_Exception("$fieldName is not a valid integer", 2001, array('error_field' => $fieldName, "type" => "integer"));
+ }
}
// Check our field length
$options = array_map("strtolower", $options);
$value = array_search($value, $options);
if ($value === FALSE) {
- throw new Exception($errorMsg);
+ throw new API_Exception($errorMsg, 2001, array('error_field' => $fieldName));
}
}
$result = civicrm_api('activity', 'create', $params);
$this->assertEquals($result['is_error'], 1, "In line " . __LINE__);
$this->assertEquals("'44' is not a valid option for field priority_id", $result['error_message']);
- $this->assertEquals('priority_id',$result['error_field']);
+ $this->assertEquals(2001, $result['error_code']);
+ $this->assertEquals('priority_id', $result['error_field']);
}
function testActivityCreateWithValidStringPriority() {
$params['target_contact_id'] = array($contact2 => $contact2);
$result = civicrm_api('Activity', 'Create', $params);
- $result = civicrm_api('activity', 'create', $params);
$activityId = $result['id'];
$this->assertAPISuccess($result);
$getParams = array(