function EntityDefinitionUpdateTest::testUpdateFieldableEntityTypeWithoutInCodeDefinition

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

Tests updating a fieldable entity type that doesn't exist in code anymore.

@covers ::updateFieldableEntityType

File

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

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testUpdateFieldableEntityTypeWithoutInCodeDefinition() : void {
    $entity_type = clone $this->entityTypeManager
        ->getDefinition('entity_test_update');
    $field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('entity_test_update');
    // Remove the entity type definition. This is the same thing as removing the
    // code that defines it.
    $this->deleteEntityType();
    // Rename the base table, update the fieldable entity type and check that
    // the table has been renamed.
    $entity_type->set('base_table', 'entity_test_update_new');
    $this->entityDefinitionUpdateManager
        ->updateFieldableEntityType($entity_type, $field_storage_definitions);
    $this->assertTrue($this->database
        ->schema()
        ->tableExists('entity_test_update_new'), 'The base table has been renamed.');
    $this->assertFalse($this->database
        ->schema()
        ->tableExists('entity_test_update'), 'The old base table does not exist anymore.');
}

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