$entity_field_manager = \Drupal::
service('entity_field.manager'
);
$entity_field_manager->
clearCachedFieldDefinitions();
$definitions =
$entity_field_manager->
getBaseFieldDefinitions($entity_type);
$this->
assertFalse($definitions['name'
]->
isTranslatable(), 'Field translatability can be disabled programmatically.'
);
$this->state->
set('entity_test.field_definitions.translatable',
['name' => TRUE
]);
$entity_field_manager->
clearCachedFieldDefinitions();
$definitions =
$entity_field_manager->
getBaseFieldDefinitions($entity_type);
$this->
assertTrue($definitions['name'
]->
isTranslatable(), 'Field translatability can be enabled programmatically.'
);
// Check that field translatability is disabled by default.
$base_field_definitions = EntityTestMulRev::
baseFieldDefinitions($this->entityTypeManager->
getDefinition($entity_type));
$this->
assertTrue(!
isset($base_field_definitions['id'
]->translatable
), 'Translatability for the <em>id</em> field is not defined.'
);
$this->
assertFalse($definitions['id'
]->
isTranslatable(), 'Field translatability is disabled by default.'
);
// Check that entity id keys have the expect translatability.
$translatable_fields =
[ 'id' => TRUE,
'uuid' => TRUE,
'revision_id' => TRUE,
'type' => TRUE,
'langcode' => FALSE,
];