Test foreign key support.
function testFieldSqlStorageForeignKeys() {
// Create a decimal field.
$field_name = 'testfield';
$field = array(
'field_name' => $field_name,
'type' => 'text',
);
$field = field_create_field($field);
// Retrieve the field and instance with field_info and verify the foreign
// keys are in place.
$field = field_info_field($field_name);
$this
->assertEqual($field['foreign keys']['format']['table'], 'filter_format', 'Foreign key table name preserved through CRUD');
$this
->assertEqual($field['foreign keys']['format']['columns']['format'], 'format', 'Foreign key column name preserved through CRUD');
// Now grab the SQL schema and verify that too.
$schema = drupal_get_schema(_field_sql_storage_tablename($field));
$this
->assertEqual(count($schema['foreign keys']), 1, t("There is 1 foreign key in the schema"));
$foreign_key = reset($schema['foreign keys']);
$filter_column = _field_sql_storage_columnname($field['field_name'], 'format');
$this
->assertEqual($foreign_key['table'], 'filter_format', 'Foreign key table name preserved in the schema');
$this
->assertEqual($foreign_key['columns'][$filter_column], 'format', 'Foreign key column name preserved in the schema');
}