FieldTranslationsTestCase::setUp

  1. drupal
    1. 8
    2. 7
Versions
7 FieldTranslationsTestCase::setUp()

Set the default field storage backend for fields created during tests.

Code

modules/field/tests/field.test, line 2621

<?php
function setUp() {
  parent::setUp('locale', 'field_test');

  $this->field_name = drupal_strtolower($this->randomName() . '_field_name');

  $this->entity_type = 'test_entity';

  $field = array(
    'field_name' => $this->field_name, 
    'type' => 'test_field', 
    'cardinality' => 4, 
    'translatable' => TRUE,
  );
  field_create_field($field);
  $this->field = field_read_field($this->field_name);

  $instance = array(
    'field_name' => $this->field_name, 
    'entity_type' => $this->entity_type, 
    'bundle' => 'test_bundle',
  );
  field_create_instance($instance);
  $this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle');

  require_once DRUPAL_ROOT . '/includes/locale.inc';
  for ($i = 0; $i < 3; ++$i) {
    locale_add_language('l' . $i, $this->randomString(), $this->randomString());
  }
}
?>