You are here

public function EntityDefinitionUpdateTest::testUpdateEntityTypeWithoutInCodeDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testUpdateEntityTypeWithoutInCodeDefinition()

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

@covers ::updateEntityType

File

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

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testUpdateEntityTypeWithoutInCodeDefinition() {
  $entity_type = clone $this->entityTypeManager
    ->getDefinition('entity_test_update');

  // Remove the entity type definition. This is the same thing as removing the
  // code that defines it.
  $this
    ->deleteEntityType();

  // Add an entity index, update the entity type and check that the index has
  // been created.
  $this
    ->addEntityIndex();
  $this->entityDefinitionUpdateManager
    ->updateEntityType($entity_type);
  $this
    ->assertTrue($this->database
    ->schema()
    ->indexExists('entity_test_update', 'entity_test_update__new_index'), 'Index created.');
}