function entity_test_install in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/entity_test/entity_test.install \entity_test_install()
- 9 core/modules/system/tests/modules/entity_test/entity_test.install \entity_test_install()
Implements hook_install().
3 calls to entity_test_install()
- EntityFieldTest::setUp in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - EntityLanguageTestBase::setUp in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityLanguageTestBase.php - FieldAccessTest::setUp in core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldAccessTest.php
File
- core/
modules/ system/ tests/ modules/ entity_test/ entity_test.install, line 14 - Install, update and uninstall functions for the entity_test module.
Code
function entity_test_install() {
foreach (entity_test_entity_types() as $entity_type) {
// Auto-create fields for testing.
FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
])
->save();
FieldConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'bundle' => $entity_type,
'label' => 'Test text-field',
'translatable' => FALSE,
])
->save();
\Drupal::service('entity_display.repository')
->getFormDisplay($entity_type, $entity_type)
->setComponent('field_test_text', [
'type' => 'text_textfield',
])
->save();
}
}