You are here

protected function TranslationTest::setUp in Drupal 8

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

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

Overrides FieldKernelTestBase::setUp

File

core/modules/field/tests/src/Kernel/TranslationTest.php, line 73

Class

TranslationTest
Tests multilanguage fields logic.

Namespace

Drupal\Tests\field\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('node');
  $this
    ->installConfig([
    'language',
  ]);
  $this->fieldName = mb_strtolower($this
    ->randomMachineName());
  $this->entityType = 'entity_test';
  $this->fieldStorageDefinition = [
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityType,
    'type' => 'test_field',
    'cardinality' => 4,
  ];
  $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
  $this->fieldStorage
    ->save();
  $this->fieldDefinition = [
    'field_storage' => $this->fieldStorage,
    'bundle' => 'entity_test',
  ];
  $this->field = FieldConfig::create($this->fieldDefinition);
  $this->field
    ->save();
  for ($i = 0; $i < 3; ++$i) {
    ConfigurableLanguage::create([
      'id' => 'l' . $i,
      'label' => $this
        ->randomString(),
    ])
      ->save();
  }
}