$this->
assertFalse($entity->
hasField('custom_bundle_field'
));
// Check that the custom bundle has the defined custom field and check
// saving and deleting of custom field data.
$entity =
$storage->
create([ 'type' => 'custom',
]);
$this->
assertTrue($entity->
hasField('custom_bundle_field'
));
// Ensure that the field exists in the field map.
$field_map = \Drupal::
service('entity_field.manager'
)->
getFieldMap();
$this->
assertEquals(['type' => 'string', 'bundles' =>
['custom' => 'custom'
]],
$field_map['entity_test_update'
]['custom_bundle_field'
]);
$entity->custom_bundle_field->value = 'swanky';
$entity->
save();
$storage->
resetCache();
$entity =
$storage->
load($entity->
id());
$this->
assertEquals('swanky',
$entity->custom_bundle_field->value, 'Entity was saved correctly'
);
$entity->custom_bundle_field->value = 'cozy';
$entity->
save();
$storage->
resetCache();