public function EntityDefinitionUpdateTest::testInstallAdditionalBaseFieldDuringFieldableEntityTypeInstallation in Drupal 9
Same name and namespace in other branches
- 8 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.
@covers ::installFieldableEntityType
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDefinitionUpdateTest.php, line 156
Class
- EntityDefinitionUpdateTest
- Tests EntityDefinitionUpdateManager functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testInstallAdditionalBaseFieldDuringFieldableEntityTypeInstallation() {
$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);
}