summaryrefslogtreecommitdiff
path: root/modules/field/field.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-14 14:55:12 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-14 14:55:12 +0000
commita243e821fa8c19f5cdaae5af0495fcccdda70125 (patch)
treebda3f7e669281b2bd2d2d49fdb7a44c296d2d92e /modules/field/field.test
parent7a9fc8a33d49badf34b6f41bed978a2aad004745 (diff)
downloadbrdo-a243e821fa8c19f5cdaae5af0495fcccdda70125.tar.gz
brdo-a243e821fa8c19f5cdaae5af0495fcccdda70125.tar.bz2
- Pactch #569224 by bangpound: expose field storage details through field attach.
Diffstat (limited to 'modules/field/field.test')
-rw-r--r--modules/field/field.test41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/field/field.test b/modules/field/field.test
index cfb7655ad..1fd410e78 100644
--- a/modules/field/field.test
+++ b/modules/field/field.test
@@ -274,6 +274,47 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
}
/**
+ * Test storage details alteration.
+ *
+ * @see field_test_storage_details_alter()
+ */
+ function testFieldStorageDetailsAlter() {
+ $field_name = 'field_test_change_my_details';
+ $field = array(
+ 'field_name' => $field_name,
+ 'type' => 'test_field',
+ 'cardinality' => 4,
+ 'storage' => array('type' => 'field_test_storage'),
+ );
+ $field = field_create_field($field);
+ $instance = array(
+ 'field_name' => $field_name,
+ 'bundle' => 'test_bundle',
+ );
+ field_create_instance($instance);
+
+ $field = field_info_field($instance['field_name']);
+ $instance = field_info_instance($instance['field_name'], $instance['bundle']);
+
+ // The storage details are indexed by a storage engine type.
+ $this->assertTrue(array_key_exists('drupal_variables', $instance['storage_details']), t('The storage type is Drupal variables.'));
+
+ $details = $instance['storage_details']['drupal_variables'];
+
+ // The field_test storage details are indexed by variable name. The details
+ // are altered, so moon and mars are correct for this test.
+ $this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), t('Moon is available in the instance array.'));
+ $this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), t('Mars is available in the instance array.'));
+
+ // Test current and revision storage details together because the columns
+ // are the same.
+ foreach ((array) $field['columns'] as $column_name => $attributes) {
+ $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'moon[FIELD_LOAD_CURRENT]')));
+ $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'mars[FIELD_LOAD_REVISION]')));
+ }
+ }
+
+ /**
* Tests insert and update with missing or NULL fields.
*/
function testFieldAttachSaveMissingData() {