function TranslationTest::setUp

Same name in this branch

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

Overrides FieldTestBase::setUp

File

drupal/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php, line 35
Definition of Drupal\field\Tests\TranslationTest.

Class

TranslationTest
Unit test class for the multilanguage fields logic.

Namespace

Drupal\field\Tests

Code

function setUp() {
  parent::setUp();
  $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');
  for ($i = 0; $i < 3; ++$i) {
    $language = new Language(array(
      'langcode' => 'l' . $i,
      'name' => $this
        ->randomString(),
    ));
    language_save($language);
  }
}