function EntityUpdateAddRevisionTranslationAffectedTest::testDeletedEntityType

Tests the 'revision_translation_affected' field on a deleted entity type.

File

core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionTranslationAffectedTest.php, line 93

Class

EntityUpdateAddRevisionTranslationAffectedTest
Tests the upgrade path for adding the 'revision_translation_affected' field.

Namespace

Drupal\Tests\system\Functional\Update

Code

public function testDeletedEntityType() {
  // Delete the entity type before running the update. This tests the case
  // where the code of an entity type has been removed but its definition has
  // not yet been uninstalled.
  $this->deleteEntityType();
  \Drupal::entityTypeManager()->clearCachedDefinitions();
  // Check that the test entity type does not have the
  // 'revision_translation_affected' field before running the updates.
  $field_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions('entity_test_update');
  $this->assertFalse(isset($field_storage_definitions['revision_translation_affected']));
  $this->runUpdates();
  // Check that the 'revision_translation_affected' field has not been added
  // by system_update_8402().
  $field_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions('entity_test_update');
  $this->assertFalse(isset($field_storage_definitions['revision_translation_affected']));
  // Check that the entity type definition has not been updated with the new
  // 'revision_translation_affected' key.
  $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('entity_test_update');
  $this->assertFalse($entity_type->getKey('revision_translation_affected'));
}

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