// Normally it would make sense to load the default revision in this
// case, however that would mean simulating here the logic that we need
// to test, thus "masking" possible flaws. To avoid that, we simply
// pretend we are starting from an earlier non translated revision.
// This ensures that the we can check that the merging logic is applied
// also when adding a new translation.
$latest_affected_revision_id = 1;
} $previous_revision_id =
(int) $entity->
getLoadedRevisionId();
/** @var \Drupal\Core\Entity\ContentEntityInterface $latest_affected_revision */
$latest_affected_revision =
$this->storage->
loadRevision($latest_affected_revision_id);
$translation =
$latest_affected_revision->
hasTranslation($active_langcode) ?
$latest_affected_revision->
getTranslation($active_langcode) :
$latest_affected_revision->
addTranslation($active_langcode);
$entity =
$this->storage->
createRevision($translation,
$default_revision);
$this->
assertEquals($default_revision,
$entity->
isDefaultRevision());
$this->
assertEquals($translation->
getLoadedRevisionId(),
$entity->
getLoadedRevisionId());
$this->
assertEquals($previous_label,
$entity->
label(),
$this->
formatMessage('Loaded translatable field value does not match the previous one.'
));
} // Check that the previous untranslatable field value is loaded in the new
// revision as expected. When we are dealing with a non default translation
// the expected value is always the one stored in the default revision, as
// untranslatable fields can only be changed in the default translation or