1.20.x field.test | FieldInfoTestCase::testFieldPrepare() |
Test that cached field definitions are ready for current runtime context.
File
- modules/
field/ tests/ field.test, line 1320 - Tests for field.module.
Class
Code
function testFieldPrepare() {
$field_definition = array(
'field_name' => 'field',
'type' => 'test_field',
);
field_create_field($field_definition);
// Simulate a stored field definition missing a field setting (e.g. a
// third-party module adding a new field setting has been enabled, and
// existing fields do not know the setting yet).
$config = config('field.field.' . $field_definition['field_name']);
$config->set('settings', array());
$config->save();
field_cache_clear();
// Read the field back.
$field = field_info_field($field_definition['field_name']);
// Check that all expected settings are in place.
$field_type = field_info_field_types($field_definition['type']);
$this->assertIdentical($field['settings'], $field_type['settings'], 'All expected default field settings are present.');
}