function entity_test_install

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.install \entity_test_install()
  2. 10 core/modules/system/tests/modules/entity_test/entity_test.install \entity_test_install()
  3. 11.x core/modules/system/tests/modules/entity_test/entity_test.install \entity_test_install()

Implements hook_install().

4 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
EntityValidationTest::setUp in core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.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

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();
    }
}

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