'entity_type' => 'entity_test',
'bundle' => 'entity_test',
];
FieldConfig::
create($field_definition)->
save();
$another_field_definition =
$field_definition;
$another_field_definition['field_name'
] =
$another_field_storage_definition['field_name'
];
FieldConfig::
create($another_field_definition)->
save();
// Test that the first field is not deleted, and then delete it.
$field_storage_config_storage = \Drupal::
entityTypeManager()->
getStorage('field_storage_config'
);
$field_storage =
current($field_storage_config_storage->
loadByProperties(['field_name' =>
$field_storage_definition['field_name'
], 'include_deleted' => TRUE
]));
$this->
assertFalse($field_storage->
isDeleted());
FieldStorageConfig::
loadByName('entity_test',
$field_storage_definition['field_name'
])->
delete();
// Make sure that the field storage is deleted as it had no data.
$field_storages =
$field_storage_config_storage->
loadByProperties(['field_name' =>
$field_storage_definition['field_name'
], 'include_deleted' => TRUE
]);
$this->
assertCount(0,
$field_storages, 'Field storage was deleted'
);
// Make sure that this field is marked as deleted when it is
// specifically loaded.
$fields = \Drupal::
entityTypeManager()->
getStorage('field_config'
)->
loadByProperties(['entity_type' => 'entity_test', 'field_name' =>
$field_definition['field_name'
], 'bundle' =>
$field_definition['bundle'
], 'include_deleted' => TRUE
]);
$this->
assertCount(0,
$fields, 'Field storage was deleted'
);