/**
* Tests updating entity schema when there are no existing entities.
*/
public function testEntityTypeUpdateWithoutData() { // The 'entity_test_update' entity type starts out non-revisionable, so
// ensure the revision table hasn't been created during setUp().
$this->
assertFalse($this->database->
schema()->
tableExists('entity_test_update_revision'
), 'Revision table not created for entity_test_update.'
);
// Update it to be revisionable and ensure the definition update manager
// reports that an update is needed.
$this->
updateEntityTypeToRevisionable();
$this->
assertTrue($this->entityDefinitionUpdateManager->
needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'
);
$expected =
[ 'entity_test_update' =>
[ t('The %entity_type entity type needs to be updated.',
['%entity_type' =>
$this->entityTypeManager->
getDefinition('entity_test_update'
)->
getLabel()]),
// The revision key is now defined, so the revision field needs to be
// created.
t('The %field_name field needs to be installed.',
['%field_name' => 'Revision ID'
]),
t('The %field_name field needs to be installed.',
['%field_name' => 'Default revision'
]),
],
];
$this->
assertEquals($expected,
$this->entityDefinitionUpdateManager->
getChangeSummary(), 'EntityDefinitionUpdateManager reports the expected change summary.'
);