1 field.test FieldSchemaAlterTestCase::testImageFieldSchemaAlter()

Tests a hook_field_schema_alter() implementation.

See also

field_test_schema_alter_field_schema_alter()

File

core/modules/field/tests/field.test, line 2615
Tests for field.module.

Class

FieldSchemaAlterTestCase
Tests that the field schema can be altered with hook_field_schema_alter().

Code

function testImageFieldSchemaAlter() {
  $test_field = array(
    'field_name' => backdrop_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 = backdrop_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'));
}