function FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesRemoveBackupTables

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesRemoveBackupTables()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesRemoveBackupTables()
  3. 11.x 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 679

Class

FieldableEntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager's fieldable entity update functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testFieldableEntityTypeUpdatesRemoveBackupTables() : void {
  $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.