diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php
index 67f6037..f7150d3 100644
--- a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php
+++ b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php
@@ -208,8 +208,12 @@ public function testEntitySaveOrder() {
     $entity->name->value = $this->randomMachineName();
     // Now save the term.
     $term->save();
+    // Now serialize it.
+    $entity = serialize($entity);
+    // And unserialize it.
+    $entity = unserialize($entity);
     // Now attempt to get the entity value.
-    $entity->get('field_test_taxonomy_term');
+    $entity->get('field_test_taxonomy_term')->entity;
     // And then the entity.
     $entity->save();
     $this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $term->id());
