public function testTranslatableFieldSaveLoad() { /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
$entity_type =
$this->container->
get('entity_type.manager'
)->
getDefinition('media'
);
$this->
assertTrue($entity_type->
isTranslatable(), 'Media is translatable.'
);
// Check if the translation handler uses the content_translation handler.
$translation_handler_class =
$entity_type->
getHandlerClass('translation'
);
$this->
assertEquals(ContentTranslationHandler::
class,
$translation_handler_class, 'Translation handler is set to use the content_translation handler.'
);
// Prepare the field translations.
$source_field_definition =
$this->testTranslationMediaType->
getSource()->
getSourceFieldDefinition($this->testTranslationMediaType
);
$source_field_storage =
$source_field_definition->
getFieldStorageDefinition();
/** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $media_storage */
$media_storage =
$this->container->
get('entity_type.manager'
)->
getStorage('media'
);
/** @var \Drupal\media\Entity\Media $media */
$media =
$media_storage->
create([ 'bundle' =>
$this->testTranslationMediaType->
id(),
'name' => 'Unnamed',
]);
$field_translations =
[];
$available_langcodes =
array_keys($this->container->
get('language_manager'
)->
getLanguages());