$contactID = $this->individualCreate();
//create Custom Group
- $customGroup = Custom::createGroup($params, 'Individual', TRUE);
+ $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
//create Custom Field of data type Date
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'Date',
- 'htmlType' => 'Select Date',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'Date',
+ 'html_type' => 'Select Date',
+ 'default_value' => '',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
// Retrieve the field ID for sample custom field 'test_Date'
$params = array('label' => 'test_Date');
$field = array();
CRM_Core_BAO_CustomField::retrieve($params, $field);
- $fieldID = $field['id'];
+ $fieldID = $customField['id'];
// Set test_Date to a valid date value
$date = '20080608000000';
'custom_' . $fieldID => $badDate,
);
- $errorScope = CRM_Core_TemporaryErrorScope::useException();
+ CRM_Core_TemporaryErrorScope::useException();
$message = NULL;
try {
- $result = CRM_Core_BAO_CustomValueTable::setValues($params);
+ CRM_Core_BAO_CustomValueTable::setValues($params);
}
catch (Exception $e) {
$message = $e->getMessage();
$this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).');
// Cleanup
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
* Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio
*/
public function testSetGetValuesYesNoRadio() {
- $params = array();
$contactID = $this->individualCreate();
- //create Custom Group
- $customGroup = Custom::createGroup($params, 'Individual', TRUE);
+ $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
//create Custom Field of type YesNo(Boolean) Radio
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'Boolean',
- 'htmlType' => 'Radio',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'Boolean',
+ 'html_type' => 'Radio',
+ 'default_value' => '',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
// Retrieve the field ID for sample custom field 'test_Boolean'
$params = array('label' => 'test_Boolean');
//get field Id
CRM_Core_BAO_CustomField::retrieve($params, $field);
- $fieldID = $field['id'];
+ $fieldID = $customField['id'];
// valid boolean value '1' for Boolean Radio
$yesNo = '1';
$this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).');
// Check that the YesNo radio value is stored
- $values = array();
$params = array(
'entityID' => $contactID,
'custom_' . $fieldID => 1,
'custom_' . $fieldID => $badYesNo,
);
- $errorScope = CRM_Core_TemporaryErrorScope::useException();
+ CRM_Core_TemporaryErrorScope::useException();
$message = NULL;
try {
- $result = CRM_Core_BAO_CustomValueTable::setValues($params);
+ CRM_Core_BAO_CustomValueTable::setValues($params);
}
catch (Exception $e) {
$message = $e->getMessage();
);
// Cleanup
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
parent::setUp();
}
-
/**
* Test store function for country.
*/
public function testStoreCountry() {
$params = array();
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $customGroup = $this->customGroupCreate();
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'Country',
- 'htmlType' => 'Select Country',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'Country',
+ 'html_type' => 'Select Country',
+ 'default_value' => '',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params[] = array(
- $customField->id => array(
+ $customField['id'] => array(
'value' => 1228,
'type' => 'Country',
- 'custom_field_id' => $customField->id,
- 'custom_group_id' => $customGroup->id,
- 'table_name' => 'civicrm_value_test_group_' . $customGroup->id,
- 'column_name' => 'test_Country_' . $customField->id,
+ 'custom_field_id' => $customField['id'],
+ 'custom_group_id' => $customGroup['id'],
+ 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'],
+ 'column_name' => $customField['values'][$customField['id']]['column_name'],
'file_id' => '',
),
);
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
- // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', )
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
/**
* Test store function for file.
*/
- public function atestStoreFile() {
- $params = array();
+ public function testStoreFile() {
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $file = $this->callAPISuccess('File', 'create', array('uri' => 'dummy_data'));
+ $customGroup = $this->customGroupCreate();
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'File',
- 'htmlType' => 'File',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'File',
+ 'html_type' => 'File',
+ 'default_value' => '',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params[] = array(
- $customField->id => array(
+ $customField['id'] => array(
'value' => 'i/contact_house.png',
'type' => 'File',
- 'custom_field_id' => $customField->id,
- 'custom_group_id' => $customGroup->id,
- 'table_name' => 'civicrm_value_test_group_' . $customGroup->id,
- 'column_name' => 'test_File_' . $customField->id,
- 'file_id' => 1,
+ 'custom_field_id' => $customField['id'],
+ 'custom_group_id' => $customGroup['id'],
+ 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'],
+ 'column_name' => $customField['values'][$customField['id']]['column_name'],
+ 'file_id' => $file['id'],
),
);
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
- // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', )
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
* Test store function for state province.
*/
public function testStoreStateProvince() {
- $params = array();
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $customGroup = $this->customGroupCreate();
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'StateProvince',
- 'htmlType' => 'Select State/Province',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'StateProvince',
+ 'html_type' => 'Select State/Province',
+ 'default_value' => '',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params[] = array(
- $customField->id => array(
+ $customField['id'] => array(
'value' => 1029,
'type' => 'StateProvince',
- 'custom_field_id' => $customField->id,
- 'custom_group_id' => $customGroup->id,
- 'table_name' => 'civicrm_value_test_group_' . $customGroup->id,
- 'column_name' => 'test_StateProvince_' . $customField->id,
+ 'custom_field_id' => $customField['id'],
+ 'custom_group_id' => $customGroup['id'],
+ 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'],
+ 'column_name' => $customField['values'][$customField['id']]['column_name'],
'file_id' => 1,
),
);
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
public function testStoreDate() {
$params = array();
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $customGroup = $this->customGroupCreate();
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'Date',
- 'htmlType' => 'Select Date',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'Date',
+ 'html_type' => 'Select Date',
+ 'default_value' => '',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params[] = array(
- $customField->id => array(
+ $customField['id'] => array(
'value' => '20080608000000',
'type' => 'Date',
- 'custom_field_id' => $customField->id,
- 'custom_group_id' => $customGroup->id,
- 'table_name' => 'civicrm_value_test_group_' . $customGroup->id,
- 'column_name' => 'test_Date_' . $customField->id,
+ 'custom_field_id' => $customField['id'],
+ 'custom_group_id' => $customGroup['id'],
+ 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'],
+ 'column_name' => $customField['values'][$customField['id']]['column_name'],
'file_id' => '',
),
);
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
- // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', )
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
public function testStoreRichTextEditor() {
$params = array();
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $customGroup = $this->customGroupCreate();
$fields = array(
- 'groupId' => $customGroup->id,
- 'htmlType' => 'RichTextEditor',
- 'dataType' => 'Memo',
+ 'custom_group_id' => $customGroup['id'],
+ 'html_type' => 'RichTextEditor',
+ 'data_type' => 'Memo',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params[] = array(
- $customField->id => array(
+ $customField['id'] => array(
'value' => '<p><strong>This is a <u>test</u></p>',
'type' => 'Memo',
- 'custom_field_id' => $customField->id,
- 'custom_group_id' => $customGroup->id,
- 'table_name' => 'civicrm_value_test_group_' . $customGroup->id,
- 'column_name' => 'test_Memo_' . $customField->id,
+ 'custom_field_id' => $customField['id'],
+ 'custom_group_id' => $customGroup['id'],
+ 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'],
+ 'column_name' => $customField['values'][$customField['id']]['column_name'],
'file_id' => '',
),
);
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
- // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', )
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
/**
* Test getEntityValues function for stored value.
*/
- public function testgetEntityValues() {
+ public function testGetEntityValues() {
$params = array();
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $customGroup = $this->customGroupCreate(array('extends' => 'Individual'));
$fields = array(
- 'groupId' => $customGroup->id,
- 'htmlType' => 'RichTextEditor',
- 'dataType' => 'Memo',
+ 'custom_group_id' => $customGroup['id'],
+ 'html_type' => 'RichTextEditor',
+ 'data_type' => 'Memo',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params[] = array(
- $customField->id => array(
+ $customField['id'] => array(
'value' => '<p><strong>This is a <u>test</u></p>',
'type' => 'Memo',
- 'custom_field_id' => $customField->id,
- 'custom_group_id' => $customGroup->id,
- 'table_name' => 'civicrm_value_test_group_' . $customGroup->id,
- 'column_name' => 'test_Memo_' . $customField->id,
+ 'custom_field_id' => $customField['id'],
+ 'custom_group_id' => $customGroup['id'],
+ 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'],
+ 'column_name' => $customField['values'][$customField['id']]['column_name'],
'file_id' => '',
),
);
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
- // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', )
$entityValues = CRM_Core_BAO_CustomValueTable::getEntityValues($contactID, 'Individual');
- $this->assertEquals($entityValues[$customField->id], '<p><strong>This is a <u>test</u></p>',
+ $this->assertEquals($entityValues[$customField['id']], '<p><strong>This is a <u>test</u></p>',
'Checking same for returned value.'
);
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
public function testCustomGroupMultiple() {
$params = array();
$contactID = $this->individualCreate();
- $customGroup = Custom::createGroup($params, 'Individual');
+ $customGroup = $this->customGroupCreate();
$fields = array(
- 'groupId' => $customGroup->id,
- 'dataType' => 'String',
- 'htmlType' => 'Text',
+ 'custom_group_id' => $customGroup['id'],
+ 'data_type' => 'String',
+ 'html_type' => 'Text',
);
- $customField = Custom::createField($params, $fields);
+ $customField = $this->customFieldCreate($fields);
$params = array(
'entityID' => $contactID,
- 'custom_' . $customField->id . '_-1' => 'First String',
+ 'custom_' . $customField['id'] . '_-1' => 'First String',
);
$error = CRM_Core_BAO_CustomValueTable::setValues($params);
$newParams = array(
'entityID' => $contactID,
- 'custom_' . $customField->id => 1,
+ 'custom_' . $customField['id'] => 1,
);
$result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
- $this->assertEquals($params['custom_' . $customField->id . '_-1'], $result['custom_' . $customField->id]);
+ $this->assertEquals($params['custom_' . $customField['id'] . '_-1'], $result['custom_' . $customField['id']]);
$this->assertEquals($params['entityID'], $result['entityID']);
- Custom::deleteField($customField);
- Custom::deleteGroup($customGroup);
+ $this->customFieldDelete($customField['id']);
+ $this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}