function FieldSqlStorageTestCase::testFieldSqlSchemaForEntityWithStringIdentifier
Tests adding a field with an entity ID type of string.
File
-
modules/
field/ modules/ field_sql_storage/ field_sql_storage.test, line 116
Class
- FieldSqlStorageTestCase
- Tests field storage.
Code
function testFieldSqlSchemaForEntityWithStringIdentifier() {
// Test programmatically adding field with string ID.
$field_name = 'string_id_example';
$field = array(
'field_name' => $field_name,
'type' => 'text',
'settings' => array(
'max_length' => 255,
),
'entity_id_type' => 'string',
);
field_create_field($field);
$schema = drupal_get_schema('field_data_' . $field_name);
$this->assertEqual($schema['fields']['entity_id']['type'], 'varchar');
$this->assertEqual($schema['fields']['revision_id']['type'], 'varchar');
// Test programmatically adding field with default ID(int).
$field_name = 'default_id_example';
$field = array(
'field_name' => $field_name,
'type' => 'text',
'settings' => array(
'max_length' => 255,
),
);
field_create_field($field);
$schema = drupal_get_schema('field_data_' . $field_name);
$this->assertEqual($schema['fields']['entity_id']['type'], 'int');
$this->assertEqual($schema['fields']['revision_id']['type'], 'int');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.