You are here

protected function ContentTranslationUntranslatableFieldsTest::setUp 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::setUp()
  2. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationUntranslatableFieldsTest::setUp()

File

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

Class

ContentTranslationUntranslatableFieldsTest
Tests the untranslatable fields behaviors.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Configure one field as untranslatable.
  $this
    ->drupalLogin($this->administrator);
  $edit = [
    'settings[' . $this->entityTypeId . '][' . $this->bundle . '][fields][' . $this->fieldName . ']' => 0,
  ];
  $this
    ->drupalGet('admin/config/regional/content-language');
  $this
    ->submitForm($edit, 'Save configuration');

  /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
  $entity_field_manager = $this->container
    ->get('entity_field.manager');
  $entity_field_manager
    ->clearCachedFieldDefinitions();
  $definitions = $entity_field_manager
    ->getFieldDefinitions($this->entityTypeId, $this->bundle);
  $this
    ->assertFalse($definitions[$this->fieldName]
    ->isTranslatable());
}