You are here

protected function EntityLanguageTestBase::toggleFieldTranslatability in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php \Drupal\system\Tests\Entity\EntityLanguageTestBase::toggleFieldTranslatability()

Toggles field storage translatability.

Parameters

string $entity_type: The type of the entity fields are attached to.

1 call to EntityLanguageTestBase::toggleFieldTranslatability()
FieldTranslationSqlStorageTest::testFieldSqlStorage in core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php
Tests field SQL storage.

File

core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php, line 128
Contains \Drupal\system\Tests\Entity\EntityLanguageTestBase.

Class

EntityLanguageTestBase
Base class for language-aware entity tests.

Namespace

Drupal\system\Tests\Entity

Code

protected function toggleFieldTranslatability($entity_type, $bundle) {
  $fields = array(
    $this->fieldName,
    $this->untranslatableFieldName,
  );
  foreach ($fields as $field_name) {
    $field = FieldConfig::loadByName($entity_type, $bundle, $field_name);
    $translatable = !$field
      ->isTranslatable();
    $field
      ->set('translatable', $translatable);
    $field
      ->save();
    $field = FieldConfig::loadByName($entity_type, $bundle, $field_name);
    $this
      ->assertEqual($field
      ->isTranslatable(), $translatable, 'Field translatability changed.');
  }
  \Drupal::cache('entity')
    ->deleteAll();
}