diff -u b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php --- b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php @@ -196,14 +196,24 @@ // Clone the entity. $clone = clone $entity; - // Alter the uuid field of the cloned entity translation and assert that - // the change has not been propagated to the original entity. We first have - // to call the ::uuid() method on the original entity as it is going to - // cache the field value into the $entityKeysProperty of the entity object - // and we want to check that the cloned and the original entity aren't - // sharing the same reference to that local cache property. - $clone->{$entity->getEntityType()->getKey('uuid')}->value = 'test-change'; + // Alter a non-translatable and a translatable entity key fields of the + // cloned entity and assert that retrieving the value through the entity + // keys local cache will be different for the cloned and the original + // entity. + // We first have to call the ::uuid() and ::label() method on the original + // entity as it is going to cache the field values into the $entityKeys and + // $translatableEntityKeys properties of the entity object and we want to + // check that the cloned and the original entity aren't sharing the same + // reference to those local cache properties. + $uuid_field_name = $entity->getEntityType()->getKey('uuid'); + $this->assertFalse($entity->getFieldDefinition($uuid_field_name)->isTranslatable()); + $clone->$uuid_field_name->value = 'test-change-uuid'; $this->assertNotEquals($entity->uuid(), $clone->uuid()); + + $label_field_name = $entity->getEntityType()->getKey('label'); + $this->assertTrue($entity->getFieldDefinition($label_field_name)->isTranslatable()); + $clone->$label_field_name->value = 'test-change-label'; + $this->assertNotEquals($entity->label(), $clone->label()); } }