function EntityDefinitionUpdateTest::testBundleFieldUpdateWithEntityTypeSchemaUpdate

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testBundleFieldUpdateWithEntityTypeSchemaUpdate()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testBundleFieldUpdateWithEntityTypeSchemaUpdate()
  3. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testBundleFieldUpdateWithEntityTypeSchemaUpdate()

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

File

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

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.