You are here

protected function ContentTranslationUntranslatableFieldsTest::setupTestFields in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationUntranslatableFieldsTest::setupTestFields()
  2. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationUntranslatableFieldsTest::setupTestFields()

File

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

Class

ContentTranslationUntranslatableFieldsTest
Tests the untranslatable fields behaviors.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function setupTestFields() {
  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();
}