/** * Test civicrm_contact_check_params with check for required * params and no params */ public function testCheckParamsWithNoParams() { $params = array(); $contact = _civicrm_api3_deprecated_contact_check_params($params, FALSE); $this->assertEquals(1, $contact['is_error'], "In line " . __LINE__); }
/** * Method for creating contact. */ public function createContact(&$formatted, &$contactFields, $onDuplicate, $contactId = NULL, $requiredCheck = TRUE, $dedupeRuleGroupID = NULL) { $dupeCheck = FALSE; $newContact = NULL; if (is_null($contactId) && $onDuplicate != CRM_Import_Parser::DUPLICATE_NOCHECK) { $dupeCheck = (bool) $onDuplicate; } //get the prefix id etc if exists CRM_Contact_BAO_Contact::resolveDefaults($formatted, TRUE); require_once 'CRM/Utils/DeprecatedUtils.php'; //@todo direct call to API function not supported. // setting required check to false, CRM-2839 // plus we do our own required check in import $error = _civicrm_api3_deprecated_contact_check_params($formatted, $dupeCheck, TRUE, FALSE, $dedupeRuleGroupID); if (is_null($error) && civicrm_error(_civicrm_api3_deprecated_validate_formatted_contact($formatted))) { $error = _civicrm_api3_deprecated_validate_formatted_contact($formatted); } $newContact = $error; if (is_null($error)) { if ($contactId) { $this->formatParams($formatted, $onDuplicate, (int) $contactId); } // pass doNotResetCache flag since resetting and rebuilding cache could be expensive. $config = CRM_Core_Config::singleton(); $config->doNotResetCache = 1; $cid = CRM_Contact_BAO_Contact::createProfileContact($formatted, $contactFields, $contactId, NULL, NULL, $formatted['contact_type']); $config->doNotResetCache = 0; $contact = array('contact_id' => $cid); $defaults = array(); $newContact = CRM_Contact_BAO_Contact::retrieve($contact, $defaults); } //get the id of the contact whose street address is not parsable, CRM-5886 if ($this->_parseStreetAddress && is_object($newContact) && property_exists($newContact, 'address') && $newContact->address) { foreach ($newContact->address as $address) { if (!empty($address['street_address']) && (empty($address['street_number']) || empty($address['street_name']))) { $this->_unparsedStreetAddressContacts[] = array('id' => $newContact->id, 'streetAddress' => $address['street_address']); } } } return $newContact; }