function EntityDefinitionUpdateTest::testInstallAdditionalBaseFieldDuringFieldableEntityTypeInstallation

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

Tests installing an additional base field while installing an entity type.

@legacy-covers ::installFieldableEntityType

File

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

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testInstallAdditionalBaseFieldDuringFieldableEntityTypeInstallation() : void {
  $entity_type = clone $this->entityTypeManager
    ->getDefinition('entity_test_update');
  $field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('entity_test_update');
  // Enable the creation of a new base field during the installation of a
  // fieldable entity type.
  $this->state
    ->set('entity_test_update.install_new_base_field_during_create', TRUE);
  // Install the entity type and check that the additional base field was also
  // installed.
  $this->entityDefinitionUpdateManager
    ->installFieldableEntityType($entity_type, $field_storage_definitions);
  // Check whether the 'new_base_field' field has been installed correctly.
  $field_storage_definition = $this->entityDefinitionUpdateManager
    ->getFieldStorageDefinition('new_base_field', 'entity_test_update');
  $this->assertNotNull($field_storage_definition);
}

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