public function FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesRemoveBackupTables in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesRemoveBackupTables()
Tests the removal of the backup tables after a successful update.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldableEntityDefinitionUpdateTest.php, line 820
Class
- FieldableEntityDefinitionUpdateTest
- Tests EntityDefinitionUpdateManager's fieldable entity update functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testFieldableEntityTypeUpdatesRemoveBackupTables() {
$schema = $this->database
->schema();
// Convert the entity type to be revisionable.
$entity_type = $this
->getUpdatedEntityTypeDefinition(TRUE, FALSE);
$field_storage_definitions = $this
->getUpdatedFieldStorageDefinitions(TRUE, FALSE);
$this->entityDefinitionUpdateManager
->updateFieldableEntityType($entity_type, $field_storage_definitions);
// Check that backup tables are kept by default.
$tables = $schema
->findTables('old_%');
$this
->assertCount(4, $tables);
foreach ($tables as $table) {
$schema
->dropTable($table);
}
// Make the entity update process drop the backup tables after a successful
// update.
$settings = Settings::getAll();
$settings['entity_update_backup'] = FALSE;
new Settings($settings);
$entity_type = $this
->getUpdatedEntityTypeDefinition(TRUE, TRUE);
$field_storage_definitions = $this
->getUpdatedFieldStorageDefinitions(TRUE, TRUE);
$this->entityDefinitionUpdateManager
->updateFieldableEntityType($entity_type, $field_storage_definitions);
// Check that backup tables have been dropped.
$tables = $schema
->findTables('old_%');
$this
->assertCount(0, $tables);
}