function TranslationTest::setUp

Same name in this branch
  1. 11.x core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php \Drupal\Tests\Core\Annotation\TranslationTest::setUp()
Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/TranslationTest.php \Drupal\Tests\field\Kernel\TranslationTest::setUp()
  2. 9 core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php \Drupal\Tests\Core\Annotation\TranslationTest::setUp()
  3. 8.9.x core/modules/field/tests/src/Kernel/TranslationTest.php \Drupal\Tests\field\Kernel\TranslationTest::setUp()
  4. 8.9.x core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php \Drupal\Tests\Core\Annotation\TranslationTest::setUp()
  5. 10 core/modules/field/tests/src/Kernel/TranslationTest.php \Drupal\Tests\field\Kernel\TranslationTest::setUp()
  6. 10 core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php \Drupal\Tests\Core\Annotation\TranslationTest::setUp()

Overrides FieldKernelTestBase::setUp

File

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

Class

TranslationTest
Tests multilingual fields logic.

Namespace

Drupal\Tests\field\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->installEntitySchema('node');
    $this->installConfig([
        'language',
    ]);
    $this->fieldName = $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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.