->
create(['type' =>
$this->fieldTestData->field->
getTargetBundle()]);
$values =
$this->
_generateTestFieldValues($this->fieldTestData->field_storage->
getCardinality());
$entity->
{$this->fieldTestData->field_name
} =
$values;
$entity->
{$field_name} =
$this->
_generateTestFieldValues(1
);
$entity =
$this->
entitySaveReload($entity);
// Verify the fields are present on load
$this->
assertCount(4,
$entity->
{$this->fieldTestData->field_name
}, 'First field got loaded'
);
$this->
assertCount(1,
$entity->
{$field_name}, 'Second field got loaded'
);
// Delete the bundle.
entity_test_delete_bundle($this->fieldTestData->field->
getTargetBundle(),
$entity_type);
// Verify no data gets loaded
$controller =
$this->container->
get('entity_type.manager'
)->
getStorage($entity->
getEntityTypeId());
$controller->
resetCache();
$entity =
$controller->
load($entity->
id());
$this->
assertEmpty($entity->
{$this->fieldTestData->field_name
}, 'No data for first field'
);
$this->
assertEmpty($entity->
{$field_name}, 'No data for second field'
);
// Verify that the fields are gone.
$this->
assertNull(FieldConfig::
load('entity_test.' .
$this->fieldTestData->field->
getTargetBundle() . '.' .
$this->fieldTestData->field_name
), "First field is deleted"
);