You are here

protected function TranslationTest::setUp in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/field/src/Tests/TranslationTest.php \Drupal\field\Tests\TranslationTest::setUp()
  2. 8 core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php \Drupal\Tests\Core\Annotation\TranslationTest::setUp()
Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/TranslationTest.php \Drupal\field\Tests\TranslationTest::setUp()

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

Overrides FieldUnitTestBase::setUp

File

core/modules/field/src/Tests/TranslationTest.php, line 76
Contains \Drupal\field\Tests\TranslationTest.

Class

TranslationTest
Tests multilanguage fields logic.

Namespace

Drupal\field\Tests

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installConfig(array(
    'language',
  ));
  $this->fieldName = Unicode::strtolower($this
    ->randomMachineName());
  $this->entityType = 'entity_test';
  $this->fieldStorageDefinition = array(
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityType,
    'type' => 'test_field',
    'cardinality' => 4,
  );
  $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition);
  $this->fieldStorage
    ->save();
  $this->fieldDefinition = array(
    'field_storage' => $this->fieldStorage,
    'bundle' => 'entity_test',
  );
  $this->field = entity_create('field_config', $this->fieldDefinition);
  $this->field
    ->save();
  for ($i = 0; $i < 3; ++$i) {
    ConfigurableLanguage::create(array(
      'id' => 'l' . $i,
      'label' => $this
        ->randomString(),
    ))
      ->save();
  }
}