// Test that when untranslatable field widgets are displayed, synchronized
// field properties can be changed only in default revisions.
$this->
setUntranslatableFieldWidgetsDisplay(TRUE
);
$entity =
$this->
saveNewEntity();
$entity_id =
$entity->
id();
$this->
assertLatestRevisionFieldValues($entity_id,
[1, 1, 1, 'Alt 1 EN'
]);
/** @var \Drupal\Core\Entity\ContentEntityInterface $en_revision */
$en_revision =
$this->
createRevision($entity, FALSE
);
$en_revision->
get($this->fieldName
)->target_id = 2;
$violations =
$en_revision->
validate();
$this->
assertViolations($violations);
$it_translation =
$entity->
addTranslation('it',
$entity->
toArray());
/** @var \Drupal\Core\Entity\ContentEntityInterface $it_revision */
$it_revision =
$this->
createRevision($it_translation, FALSE
);
$metadata =
$this->contentTranslationManager->
getTranslationMetadata($it_revision);
$metadata->
setSource('en'
);
$it_revision->
get($this->fieldName
)->target_id = 2;
$it_revision->
get($this->fieldName
)->alt = 'Alt 2 IT';
$violations =
$it_revision->
validate();
$this->
assertViolations($violations);
$it_revision->
isDefaultRevision(TRUE
);