function FieldSqlNoRevisionsTestCase::testUpdateFieldSchemaWithData in Field SQL norevisions 7.2
Same name and namespace in other branches
- 7 field_sql_norevisions.test \FieldSqlNoRevisionsTestCase::testUpdateFieldSchemaWithData()
Test trying to update a field with data.
File
- ./
field_sql_norevisions.test, line 262 - Tests for field_sql_norevisions.module.
Class
- FieldSqlNoRevisionsTestCase
- Tests field storage.
Code
function testUpdateFieldSchemaWithData() {
// Create a decimal 5.2 field and add some data.
$field = array(
'field_name' => 'decimal52',
'type' => 'number_decimal',
'settings' => array(
'precision' => 5,
'scale' => 2,
),
);
$field = field_create_field($field);
$instance = array(
'field_name' => 'decimal52',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
$instance = field_create_instance($instance);
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
$entity->decimal52[LANGUAGE_NONE][0]['value'] = '1.235';
field_attach_insert('test_entity', $entity);
// Attempt to update the field in a way that would work without data.
$field['settings']['scale'] = 3;
try {
field_update_field($field);
$this
->fail(t('Cannot update field schema with data.'));
} catch (FieldException $e) {
$this
->pass(t('Cannot update field schema with data.'));
}
}