$this->
installModule('entity_schema_test'
);
$storage_definitions = \Drupal::
service('entity_field.manager'
)->
getFieldStorageDefinitions('entity_test_update'
);
\Drupal::
service('field_storage_definition.listener'
)->
onFieldStorageDefinitionCreate($storage_definitions['custom_base_field'
]);
\Drupal::
service('field_storage_definition.listener'
)->
onFieldStorageDefinitionCreate($storage_definitions['custom_bundle_field'
]);
$schema_handler =
$this->database->
schema();
$tables =
['entity_test_update', 'entity_test_update_revision', 'entity_test_update_data', 'entity_test_update_revision_data'
];
$dedicated_tables =
['entity_test_update__custom_bundle_field', 'entity_test_update_revision__custom_bundle_field'
];
// Initially only the base table and the dedicated field data table should
// exist.
foreach ($tables as $index =>
$table) { $this->
assertEquals(!
$index,
$schema_handler->
tableExists($table),
new FormattableMarkup('Entity schema correct for the @table table.',
['@table' =>
$table]));
} $this->
assertTrue($schema_handler->
tableExists($dedicated_tables[0
]),
new FormattableMarkup('Field schema correct for the @table table.',
['@table' =>
$table]));
// Update the entity type definition and check that the entity schema now
// supports translations and revisions.
$this->
updateEntityType(TRUE
);
foreach ($tables as $table) { $this->
assertTrue($schema_handler->
tableExists($table),
new FormattableMarkup('Entity schema correct for the @table table.',
['@table' =>
$table]));
} foreach ($dedicated_tables as $table) { $this->
assertTrue($schema_handler->
tableExists($table),
new FormattableMarkup('Field schema correct for the @table table.',
['@table' =>
$table]));
}