$this->
assertFalse($event_subscriber->
hasEventFired(FieldStorageDefinitionEvents::UPDATE
), 'Entity type update was not dispatched yet.'
);
\Drupal::
service('field_storage_definition.listener'
)->
onFieldStorageDefinitionUpdate($updated_storage_definition,
$storage_definition);
$this->
assertTrue($event_subscriber->
hasEventFired(FieldStorageDefinitionEvents::UPDATE
), 'Entity type update event successfully dispatched.'
);
$this->
assertTrue($event_subscriber->
hasDefinitionBeenUpdated(FieldStorageDefinitionEvents::UPDATE
), 'Last installed field storage definition was updated before the event was fired.'
);
// Check that the updated field can be retrieved from the live field storage
// definitions.
$field_storage_definitions =
$this->entityFieldManager->
getFieldStorageDefinitions('entity_test_rev'
);
$this->
assertEquals(new TranslatableMarkup('Updated field storage test'
),
$field_storage_definitions['field_storage_test'
]->
getLabel());
$this->
assertFalse($event_subscriber->
hasEventFired(FieldStorageDefinitionEvents::DELETE
), 'Entity type delete was not dispatched yet.'
);
\Drupal::
service('field_storage_definition.listener'
)->
onFieldStorageDefinitionDelete($storage_definition);
$this->
assertTrue($event_subscriber->
hasEventFired(FieldStorageDefinitionEvents::DELETE
), 'Entity type delete event successfully dispatched.'
);
$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'
);