| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
* Include class definitions
public function tearDown() {
$tablesToTruncate = array(
- 'civicrm_custom_group', 'civicrm_custom_field',
+ 'civicrm_custom_group',
+ 'civicrm_custom_field',
);
// true tells quickCleanup to drop any tables that might have been created in the test
$this->quickCleanup($tablesToTruncate, TRUE);
'is_active' => 1,
);
- $customField = $this->callAPIAndDocument('custom_field', 'create', $params, __FUNCTION__, __FILE__);
+ $customField = $this->callAPIAndDocument('custom_field', 'create', $params, __FUNCTION__, __FILE__);
$params['id'] = $customField['id'];
- $customField = $this->callAPISuccess('custom_field', 'create', $params);
+ $customField = $this->callAPISuccess('custom_field', 'create', $params);
$this->assertNotNull($customField['id'], 'in line ' . __LINE__);
}
/**
* Check for Each data type: loop through available form input types
- **/
+ */
public function testCustomFieldCreateAllAvailableFormInputs() {
$gid = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'testAllFormInputs'));
}
}
/*
- * Can't figure out the point of this?
- */
+ * Can't figure out the point of this?
+ */
/**
* @param array $params
*/
public function _buildParams($gid, $htype, $dtype) {
$params = $this->_buildBasicParams($gid, $htype, $dtype);
/* //Not Working for any type. Maybe redundant with testCustomFieldCreateWithOptionValues()
- if ($htype == 'Multi-Select')
- $params = array_merge($params, array(
- 'option_label' => array( 'Label1','Label2'),
- 'option_value' => array( 'val1', 'val2' ),
- 'option_weight' => array( 1, 2),
- 'option_status' => array( 1, 1),
- ));
- */
+ if ($htype == 'Multi-Select')
+ $params = array_merge($params, array(
+ 'option_label' => array( 'Label1','Label2'),
+ 'option_value' => array( 'val1', 'val2' ),
+ 'option_weight' => array( 1, 2),
+ 'option_status' => array( 1, 1),
+ ));
+ */
return $params;
}
* Test using example code
*/
/*function testCustomFieldCreateExample( )
- {
+ {
- $customGroup = $this->customGroupCreate('Individual','date_test_group',3);
- require_once 'api/v3/examples/CustomField/Create.php';
- $result = custom_field_create_example();
- $expectedResult = custom_field_create_expectedresult();
- $this->assertEquals($result,$expectedResult);
- }*/
+ $customGroup = $this->customGroupCreate('Individual','date_test_group',3);
+ require_once 'api/v3/examples/CustomField/Create.php';
+ $result = custom_field_create_example();
+ $expectedResult = custom_field_create_expectedresult();
+ $this->assertEquals($result,$expectedResult);
+ }*/
/**
* Check with data type - Options with option_values
$this->assertTrue(is_numeric($optionGroupID) && ($optionGroupID > 0));
$optionGroup = $this->callAPISuccess('option_group', 'getsingle', array(
- 'id' => $optionGroupID));
+ 'id' => $optionGroupID,
+ ));
$this->assertEquals($optionGroup['title'], 'Country');
$optionValueCount = $this->callAPISuccess('option_value', 'getcount', array(
- 'option_group_id' => $optionGroupID));
+ 'option_group_id' => $optionGroupID,
+ ));
$this->assertEquals(0, $optionValueCount);
}
$customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
$result = $this->callAPISuccess('custom_field', 'getsingle', array(
- 'id' => $customField['id'],
+ 'id' => $customField['id'],
'return' => array('data_type'),
));
$this->assertTrue(array_key_exists('data_type', $result));
$customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
$result = $this->callAPISuccess('custom_field', 'getsingle', array(
- 'id' => $customField['id'],
+ 'id' => $customField['id'],
'return' => 'data_type, custom_group_id',
));
$this->assertTrue(array_key_exists('data_type', $result));
$option_values = array(
array(
- 'weight' => 1,
+ 'weight' => 1,
'label' => 'Label1',
'value' => 1,
'is_active' => 1,
$this->assertNotNull($customField['id']);
$getFieldsParams = array(
'options' => array('get_options' => 'custom_' . $customField['id']),
- 'action' => 'create',
+ 'action' => 'create',
);
- $description = "Demonstrate retrieving metadata with custom field options";
+ $description = "Demonstrate retrieving metadata with custom field options";
$subfile = "GetFieldsOptions";
$fields = $this->callAPIAndDocument('contact', 'getfields', $getFieldsParams, __FUNCTION__, 'ContactTest.php', $description, $subfile, 'GetFields');
$this->assertArrayHasKey('options', $fields['values']['custom_' . $customField['id']]);
$this->assertEquals('Label1', $fields['values']['custom_' . $customField['id']]['options'][1]);
$getOptionsArray = array(
'field' => 'custom_' . $customField['id'],
- );
+ );
$description = "Demonstrates retrieving options for a custom field";
$subfile = "GetOptions";
$result = $this->callAPIAndDocument('contact', 'getoptions', $getOptionsArray, __FUNCTION__, 'ContactTest.php', $description, '', 'getoptions');
// Add some fields
$contactGroup = $this->customGroupCreate(array('extends' => 'Contact', 'title' => 'test_group_c'));
- $contactField = $this->customFieldCreate(array('custom_group_id' => $contactGroup['id'], 'label' => 'For Contacts'));
+ $contactField = $this->customFieldCreate(array(
+ 'custom_group_id' => $contactGroup['id'],
+ 'label' => 'For Contacts',
+ ));
$indivGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group_i'));
$indivField = $this->customFieldCreate(array('custom_group_id' => $indivGroup['id'], 'label' => 'For Individuals'));
$activityGroup = $this->customGroupCreate(array('extends' => 'Activity', 'title' => 'test_group_a'));
- $activityField = $this->customFieldCreate(array('custom_group_id' => $activityGroup['id'], 'label' => 'For Activities'));
+ $activityField = $this->customFieldCreate(array(
+ 'custom_group_id' => $activityGroup['id'],
+ 'label' => 'For Activities',
+ ));
// Check getfields
$this->assertEquals(
* @return array
*/
public function getCustomFieldKeys($getFieldsResult) {
- $isCustom = function($key) {
+ $isCustom = function ($key) {
return preg_match('/^custom_/', $key);
};
$r = array_values(array_filter(array_keys($getFieldsResult['values']), $isCustom));
sort($r);
return $r;
}
+
}