protected function EntityLanguageTestBase::toggleFieldTranslatability in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php \Drupal\KernelTests\Core\Entity\EntityLanguageTestBase::toggleFieldTranslatability()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php \Drupal\KernelTests\Core\Entity\EntityLanguageTestBase::toggleFieldTranslatability()
Toggles field storage translatability.
Parameters
string $entity_type: The type of the entity fields are attached to.
string $bundle: The bundle of the entity.
1 call to EntityLanguageTestBase::toggleFieldTranslatability()
- FieldTranslationSqlStorageTest::testFieldSqlStorage in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldTranslationSqlStorageTest.php - Tests field SQL storage.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityLanguageTestBase.php, line 124
Class
- EntityLanguageTestBase
- Base class for language-aware entity tests.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function toggleFieldTranslatability($entity_type, $bundle) {
$fields = [
$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
->assertEquals($translatable, $field
->isTranslatable(), 'Field translatability changed.');
}
\Drupal::cache('entity')
->deleteAll();
}