function FieldSqlNoRevisionsTestCase::testFieldSqlStorageForeignKeys in Field SQL norevisions 7.2
Same name and namespace in other branches
- 7 field_sql_norevisions.test \FieldSqlNoRevisionsTestCase::testFieldSqlStorageForeignKeys()
Test foreign key support.
File
- ./
field_sql_norevisions.test, line 378 - Tests for field_sql_norevisions.module.
Class
- FieldSqlNoRevisionsTestCase
- Tests field storage.
Code
function testFieldSqlStorageForeignKeys() {
// Create a text 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', t('Foreign key table name preserved through CRUD'));
$this
->assertEqual($field['foreign keys']['format']['columns']['format'], 'format', t('Foreign key column name preserved through CRUD'));
// Now grab the SQL schema and verify that too.
$schema = drupal_get_schema(_field_sql_norevisions_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_norevisions_columnname($field['field_name'], 'format');
$this
->assertEqual($foreign_key['table'], 'filter_format', t('Foreign key table name preserved in the schema'));
$this
->assertEqual($foreign_key['columns'][$filter_column], 'format', t('Foreign key column name preserved in the schema'));
}