function EntityDefinitionUpdateTest::testBundleFieldUpdateWithEntityTypeSchemaUpdate

Tests updating a bundle field when the entity type schema has changed.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php, line 639

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testBundleFieldUpdateWithEntityTypeSchemaUpdate() : void {
  // Add the bundle field and run the update.
  $this->addBundleField();
  $this->applyEntityUpdates();
  // Update the entity type schema to revisionable but don't run the updates
  // yet.
  $this->updateEntityTypeToRevisionable();
  // Perform a no-op update on the bundle field, which should work because
  // both the storage and the storage schema are using the last installed
  // entity type definition.
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_definition_update_manager->updateFieldStorageDefinition($entity_definition_update_manager->getFieldStorageDefinition('new_bundle_field', 'entity_test_update'));
}

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