diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index 214eab4..af5591a 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -2379,6 +2379,44 @@ class FieldCrudTestCase extends FieldTestCase { } } +class FieldSchemaAlterTestCase extends FieldTestCase { + public static function getInfo() { + return array( + 'name' => 'Field schema alteration tests', + 'description' => 'Alter the schema for a given type of field.', + 'group' => 'Field API', + ); + } + + function setUp() { + parent::setUp('field_test', 'field_test_schema_alter'); + } + + /** + * Test that new image field gets an altered alt column and a new column. + */ + function testImageFieldSchemaAlter() { + $test_field = array( + 'field_name' => drupal_strtolower($this->randomName()), + 'type' => 'test_field', + ); + field_create_field($test_field); + $test_field_name = $test_field['field_name']; + $test_field_instance_settings = array( + 'field_name' => $test_field_name, + 'entity_type' => 'test_entity', + 'bundle' => 'test_bundle', + 'deleted' => 0, + ); + $test_field_instance = field_create_instance($test_field_instance_settings); + + $table_name = _field_sql_storage_tablename($test_field_instance); + $schema = drupal_get_schema($table_name, TRUE); + $this->assertEqual('float', $schema['fields'][$test_field_name .'_value']['type']); + $this->assertTrue(db_field_exists($table_name, $test_field_name .'_additional_column')); + } +} + class FieldInstanceCrudTestCase extends FieldTestCase { protected $field; diff --git a/core/modules/field/tests/field_test_schema_alter.info b/core/modules/field/tests/field_test_schema_alter.info new file mode 100644 index 0000000..5b2ee0d --- /dev/null +++ b/core/modules/field/tests/field_test_schema_alter.info @@ -0,0 +1,6 @@ +name = "Field API Schema Alter Test" +description = "Support module for the Field API schema alter tests." +core = 8.x +package = Testing +version = VERSION +hidden = TRUE diff --git a/core/modules/field/tests/field_test_schema_alter.module b/core/modules/field/tests/field_test_schema_alter.module new file mode 100644 index 0000000..0fc8222 --- /dev/null +++ b/core/modules/field/tests/field_test_schema_alter.module @@ -0,0 +1,23 @@ + "Addtional column added to image field table.", + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ); + } +}