$this->
assertTrue($event_subscriber->
hasDefinitionBeenUpdated(FieldStorageDefinitionEvents::DELETE
), 'Last installed field storage definition was deleted before the event was fired.'
);
// Check that the deleted field can no longer be retrieved from the live
// field storage definitions.
$field_storage_definitions =
$this->entityFieldManager->
getFieldStorageDefinitions('entity_test_rev'
);
$this->
assertArrayNotHasKey('field_storage_test',
$field_storage_definitions);
// Test entity type events.
$entity_type =
$this->entityTypeManager->
getDefinition('entity_test_rev'
);
$this->
assertFalse($event_subscriber->
hasEventFired(EntityTypeEvents::CREATE
), 'Entity type create was not dispatched yet.'
);
\Drupal::
service('entity_type.listener'
)->
onEntityTypeCreate($entity_type);
$this->
assertTrue($event_subscriber->
hasEventFired(EntityTypeEvents::CREATE
), 'Entity type create event successfully dispatched.'
);
$this->
assertTrue($event_subscriber->
hasDefinitionBeenUpdated(EntityTypeEvents::CREATE
), 'Last installed entity type definition was created before the event was fired.'
);
$updated_entity_type =
clone $entity_type;
$updated_entity_type->
set('label',
new TranslatableMarkup('Updated entity test rev'
));
$this->
assertFalse($event_subscriber->
hasEventFired(EntityTypeEvents::UPDATE
), 'Entity type update was not dispatched yet.'
);
\Drupal::
service('entity_type.listener'
)->
onEntityTypeUpdate($updated_entity_type,
$entity_type);
$this->
assertTrue($event_subscriber->
hasEventFired(EntityTypeEvents::UPDATE
), 'Entity type update event successfully dispatched.'
);
$this->
assertTrue($event_subscriber->
hasDefinitionBeenUpdated(EntityTypeEvents::UPDATE
), 'Last installed entity type definition was updated before the event was fired.'
);
// Check that the updated definition can be retrieved from the live entity