$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
// type definitions.
$entity_type =
$this->entityTypeManager->
getDefinition('entity_test_rev'
);
$this->
assertEquals(new TranslatableMarkup('Updated entity test rev'
),
$entity_type->
getLabel());
$this->
assertFalse($event_subscriber->
hasEventFired(EntityTypeEvents::DELETE
), 'Entity type delete was not dispatched yet.'
);
\Drupal::
service('entity_type.listener'
)->
onEntityTypeDelete($entity_type);
$this->
assertTrue($event_subscriber->
hasEventFired(EntityTypeEvents::DELETE
), 'Entity type delete event successfully dispatched.'
);
$this->
assertTrue($event_subscriber->
hasDefinitionBeenUpdated(EntityTypeEvents::DELETE
), 'Last installed entity type definition was deleted before the event was fired.'
);
// Check that the deleted entity type can no longer be retrieved from the
// live entity type definitions.
$this->
assertNull($this->entityTypeManager->
getDefinition('entity_test_rev', FALSE
));
} /**
* Tests applying single updates.
*/