function ContentTranslationUntranslatableFieldsTest::setupTestFields

Same name in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationUntranslatableFieldsTest::setupTestFields()
  2. 8.9.x core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationUntranslatableFieldsTest::setupTestFields()
  3. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationUntranslatableFieldsTest::setupTestFields()

Overrides ContentTranslationTestBase::setupTestFields

File

core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php, line 53

Class

ContentTranslationUntranslatableFieldsTest
Tests the untranslatable fields behaviors.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function setupTestFields() : void {
    parent::setupTestFields();
    $field_storage = FieldStorageConfig::create([
        'field_name' => 'field_multilingual',
        'type' => 'test_field',
        'entity_type' => $this->entityTypeId,
        'cardinality' => 1,
    ]);
    $field_storage->save();
    FieldConfig::create([
        'field_storage' => $field_storage,
        'bundle' => $this->bundle,
        'label' => 'Untranslatable-but-visible test field',
        'translatable' => FALSE,
    ])
        ->save();
    \Drupal::service('entity_display.repository')->getFormDisplay($this->entityTypeId, $this->bundle, 'default')
        ->setComponent('field_multilingual', [
        'type' => 'test_field_widget_multilingual',
    ])
        ->save();
}

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