function FieldSqlNoRevisionsTestCase::testFieldStorageDetails in Field SQL norevisions 7.2
Same name and namespace in other branches
- 7 field_sql_norevisions.test \FieldSqlNoRevisionsTestCase::testFieldStorageDetails()
Test the storage details.
File
- ./
field_sql_norevisions.test, line 350 - Tests for field_sql_norevisions.module.
Class
- FieldSqlNoRevisionsTestCase
- Tests field storage.
Code
function testFieldStorageDetails() {
$current = _field_sql_norevisions_tablename($this->field);
$revision = _field_sql_norevisions_tablename($this->field);
// Retrieve the field and instance with field_info so the storage details are attached.
$field = field_info_field($this->field['field_name']);
$instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']);
// The storage details are indexed by a storage engine type.
$this
->assertTrue(array_key_exists('sql_norevisions', $field['storage']['details']), t('The storage type is SQL no revisions.'));
// The SQL details are indexed by table name.
$details = $field['storage']['details']['sql_norevisions'];
$this
->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), t('Table name is available in the instance array.'));
$this
->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), t('Revision table name is available in the instance array.'));
// Test current and revision storage details together because the columns
// are the same.
foreach ((array) $this->field['columns'] as $column_name => $attributes) {
$storage_column_name = _field_sql_norevisions_columnname($this->field['field_name'], $column_name);
$this
->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array(
'%value' => $column_name,
'%bin' => $current,
)));
$this
->assertEqual($details[FIELD_LOAD_REVISION][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array(
'%value' => $column_name,
'%bin' => $revision,
)));
}
}