You are here

public function ContentTranslationTest::testFieldTranslationKey in Thunder 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Integration/ContentTranslationTest.php \Drupal\Tests\thunder\Functional\Integration\ContentTranslationTest::testFieldTranslationKey()
  2. 8.3 tests/src/Functional/Integration/ContentTranslationTest.php \Drupal\Tests\thunder\Functional\Integration\ContentTranslationTest::testFieldTranslationKey()
  3. 6.2.x tests/src/Functional/Integration/ContentTranslationTest.php \Drupal\Tests\thunder\Functional\Integration\ContentTranslationTest::testFieldTranslationKey()
  4. 6.0.x tests/src/Functional/Integration/ContentTranslationTest.php \Drupal\Tests\thunder\Functional\Integration\ContentTranslationTest::testFieldTranslationKey()
  5. 6.1.x tests/src/Functional/Integration/ContentTranslationTest.php \Drupal\Tests\thunder\Functional\Integration\ContentTranslationTest::testFieldTranslationKey()

Test the field translatable property for all field configs.

@group NoUpdate

File

tests/src/Functional/Integration/ContentTranslationTest.php, line 75

Class

ContentTranslationTest
Tests integration with the content_translation.

Namespace

Drupal\Tests\thunder\Functional\Integration

Code

public function testFieldTranslationKey() {
  $whitelist = [
    'field.field.media.instagram.field_url',
    'field.field.media.pinterest.field_url',
    'field.field.media.twitter.field_author',
    'field.field.media.twitter.field_content',
    'field.field.media.twitter.field_url',
  ];
  foreach (FieldConfig::loadMultiple() as $field) {
    if (in_array($field
      ->getConfigDependencyName(), $whitelist)) {
      continue;
    }
    if (in_array($field
      ->getType(), [
      'entity_reference',
      'entity_reference_revisions',
      'datetime',
      'image',
    ])) {
      $this
        ->assertFalse($field
        ->isTranslatable(), sprintf('%s is translatable.', $field
        ->getConfigDependencyName()));
    }
    else {
      $this
        ->assertTrue($field
        ->isTranslatable(), sprintf('%s is not translatable.', $field
        ->getConfigDependencyName()));
    }
  }
}