require_once 'CiviTest/Contact.php';
require_once 'CiviTest/Custom.php';
class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
- public $_eNoticeCompliant = FALSE;
function get_info() {
return array(
'name' => 'Contact BAOs',
$customGroup = Custom::createGroup(array(), 'Individual');
$this->assertNotNull($customGroup);
$fields = array(
- 'groupId' => $customGroup->id,
+ 'custom_group_id' => $customGroup->id,
'data_type' => 'String',
'html_type' => 'Text',
);
- $customField = Custom::createField(array(), $fields);
- $this->assertNotNull($customField);
-
+ $customField = $this->customFieldCreate($fields);
+ $customField = $customField['values'][$customField['id']];
$test = $this;
$this->_testTimestamps(array(
'INSERT' => function ($contactId) use ($test, $customGroup, $customField) {
- $result = civicrm_api('contact', 'create', array(
- 'version' => 3,
+ $result = $this->callAPISuccess('contact', 'create', array(
'contact_id' => $contactId,
- 'custom_' . $customField->id => 'test-1',
+ 'custom_' . $customField['id'] => 'test-1',
));
- $test->assertAPISuccess($result);
},
'UPDATE' => function ($contactId) use ($test, $customGroup, $customField) {
CRM_Core_DAO::executeQuery(
- "UPDATE {$customGroup->table_name} SET {$customField->column_name} = 'test-2' WHERE entity_id = %1",
+ "UPDATE {$customGroup->table_name} SET {$customField['column_name']} = 'test-2' WHERE entity_id = %1",
array(1 => array($contactId, 'Integer'))
);
},
/**
* Helper function to create Custom Group
*
+ * @deprecated - use functions on test case parent class
* @return object of created group
*/
static function createGroup($group, $extends = NULL, $isMultiple = FALSE) {
/**
* Helper function to create Custom Field
- *
+ * @deprecated use parent object create fn
* @return object of created field
*/
static function createField($params, $fields = NULL) {
if (empty($params)) {
$params = array(
'custom_group_id' => $fields['groupId'],
- 'label' => empty($fields['label']) ? 'test_' . $fields['dataType'] : $fields['label'],
- 'html_type' => $fields['htmlType'],
- 'data_type' => $fields['dataType'],
+ 'label' => empty($fields['label']) ? 'test_' . CRM_Utils_Array::value('dataType', $fields) : $fields['label'],
+ 'html_type' => CRM_Utils_Array::value('htmlType', $fields),
+ 'data_type' => CRM_Utils_Array::value('dataType', $fields),
'weight' => 4,
'is_required' => 1,
'is_searchable' => 0,
/**
* Helper function to delete custom field
- *
+ * @deprecated use function on parent class
* @param object of Custom Field to delete
*/
static function deleteField($params) {
/**
* Helper function to delete custom group
- *
+ * @deprecated use function on parent class
* @param object Custom Group to delete
* @return boolean true if Group deleted, false otherwise
*/