// Since we are working with raw configuration, this needs to be unset
// manually.
// @see Drupal\field_test\Plugin\Field\FieldType\TestItem::fieldSettingsFromConfigData()
unset($config['settings'
]['config_data_from_field_setting'
]);
// Check that default values are set.
$this->
assertFalse($config['required'
], 'Required defaults to false.'
);
$this->
assertSame($config['label'
],
$this->fieldDefinition
['field_name'
], 'Label defaults to field name.'
);
$this->
assertSame('',
$config['description'
], 'Description defaults to empty string.'
);
// Check that default settings are set.
$this->
assertEquals($config['settings'
],
$field_type_manager->
getDefaultFieldSettings($this->fieldStorageDefinition
['type'
]), 'Default field settings have been written.'
);
// Check that the denormalized 'field_type' was properly written.
$this->
assertEquals($config['field_type'
],
$this->fieldStorageDefinition
['type'
]);
// Guarantee that the field/bundle combination is unique.
try { FieldConfig::
create($this->fieldDefinition
)->
save();
$this->
fail('Cannot create two fields with the same field / bundle combination.'
);
} catch (EntityStorageException
$e) { // Expected exception; just continue testing.