$this->
assertEquals('swanky',
$entity->custom_bundle_field->value, 'Entity was saved correctly'
);
$entity->custom_bundle_field->value = 'cozy';
$entity->
save();
$storage->
resetCache();
$entity =
$storage->
load($entity->
id());
$this->
assertEquals('cozy',
$entity->custom_bundle_field->value, 'Entity was updated correctly.'
);
$entity->
delete();
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping =
$storage->
getTableMapping();
$table =
$table_mapping->
getDedicatedDataTableName($entity->
getFieldDefinition('custom_bundle_field'
)->
getFieldStorageDefinition());
$result =
$this->database->
select($table, 'f'
) ->
fields('f'
) ->
condition('f.entity_id',
$entity->
id()) ->
execute();
$this->
assertFalse($result->
fetchAssoc(), 'Field data has been deleted'
);
// Create another entity to test that values are marked as deleted when a
// bundle is deleted.
$entity =
$storage->
create(['type' => 'custom', 'custom_bundle_field' => 'new'
]);
$entity->
save();
entity_test_delete_bundle('custom', 'entity_test_update'
);