function EntityDefinitionUpdateTest::testInstallFieldableEntityTypeWithoutInCodeDefinition

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

@covers ::installFieldableEntityType

File

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

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testInstallFieldableEntityTypeWithoutInCodeDefinition() {
  $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();
  // Install the entity type and check that its tables have been created.
  $this->entityDefinitionUpdateManager
    ->installFieldableEntityType($entity_type, $field_storage_definitions);
  $this->assertTrue($this->database
    ->schema()
    ->tableExists('entity_test_update'), 'The base table of the entity type has been created.');
}

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