function entity_test_install

Implements hook_install().

4 calls to entity_test_install()
EntityFieldTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Sets up Drupal unit test environment.
EntityTranslationTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
Sets up Drupal unit test environment.
EntityValidationTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
Sets up Drupal unit test environment.
FieldAccessTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php
Sets up Drupal unit test environment.

File

drupal/core/modules/system/tests/modules/entity_test/entity_test.install, line 11
Install, update and uninstall functions for the entity_test module.

Code

function entity_test_install() {

  // Auto-create a field for testing.
  $field = array(
    'field_name' => 'field_test_text',
    'type' => 'text',
    'cardinality' => 1,
    'translatable' => FALSE,
  );
  field_create_field($field);
  $entity_types = array(
    'entity_test',
    'entity_test_rev',
    'entity_test_mul',
    'entity_test_mulrev',
  );
  foreach ($entity_types as $entity_type) {
    $instance = array(
      'entity_type' => $entity_type,
      'field_name' => 'field_test_text',
      'bundle' => $entity_type,
      'label' => 'Test text-field',
    );
    field_create_instance($instance);
    entity_get_form_display($entity_type, $entity_type, 'default')
      ->setComponent('field_test_text', array(
      'type' => 'text_text',
    ))
      ->save();
  }
}