diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index 87b43f7..69ffbe6 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -268,4 +268,32 @@ public function url($rel = 'edit-form', $options = array()) {
     return parent::url($rel, $options);
   }
 
+  /**
+   * Implements the magic __sleep() method.
+   *
+   * Using the Serialize interface and serialize() / unserialize() methods
+   * breaks entity forms in PHP 5.4.
+   * @todo Investigate in https://drupal.org/node/2074253.
+   */
+  public function __sleep() {
+    // Only serialize properties from getExportProperties().
+    $keys = array_keys(array_intersect_key($this->getExportProperties(), get_object_vars($this)));
+    $keys[] = 'entityTypeId';
+    return $keys;
+  }
+
+  /**
+   * Implements the magic __wakeup() method.
+   */
+  public function __wakeup() {
+    // PHPUnit uses unserialize() on a made up string as a trick when bypassing
+    // the contructor on mock object creation. Make sure we only run on objects
+    // that have been serialized through our __sleep() method.
+    if (isset($this->entityTypeId)) {
+      // Run the values from getExportProperties() through __construct().
+      $values = array_intersect_key($this->getExportProperties(), get_object_vars($this));
+      $this->__construct($values, $this->entityTypeId);
+    }
+  }
+
 }
diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php
index 177e050..bdeeed0 100644
--- a/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php
+++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php
@@ -95,9 +95,11 @@ public function testAddEditorToNewFormat() {
       'name' => 'Monocerus',
       'format' => 'monocerus',
     );
-    $edit += $this->selectUnicornEditor();
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
-    $this->verifyUnicornEditorConfiguration($edit['format']);
+    $this->drupalGet('admin/config/content/formats/manage/monocerus');
+    $edit = $this->selectUnicornEditor();
+    $this->drupalPostForm(NULL, $edit, t('Save configuration'));
+    $this->verifyUnicornEditorConfiguration('monocerus');
   }
 
   /**
diff --git a/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php b/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php
index 18b8dc5..a46f805 100644
--- a/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php
+++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php
@@ -144,23 +144,4 @@ public function getRenderer($field_name) {
     return $widget;
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function __sleep() {
-    // Only store the definition, not external objects or derived data.
-    $keys = array_keys($this->getExportProperties());
-    $keys[] = 'entityTypeId';
-    return $keys;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function __wakeup() {
-    // Run the values from getExportProperties() through __construct().
-    $values = array_intersect_key($this->getExportProperties(), get_object_vars($this));
-    $this->__construct($values, $this->entityTypeId);
-  }
-
 }
diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php
index 503fe14..b5cb63a 100644
--- a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php
+++ b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php
@@ -689,27 +689,6 @@ public function hasData() {
   }
 
   /**
-   * Implements the magic __sleep() method.
-   *
-   * Using the Serialize interface and serialize() / unserialize() methods
-   * breaks entity forms in PHP 5.4.
-   * @todo Investigate in https://drupal.org/node/2074253.
-   */
-  public function __sleep() {
-    // Only serialize properties from getExportProperties().
-    return array_keys(array_intersect_key($this->getExportProperties(), get_object_vars($this)));
-  }
-
-  /**
-   * Implements the magic __wakeup() method.
-   */
-  public function __wakeup() {
-    // Run the values from getExportProperties() through __construct().
-    $values = array_intersect_key($this->getExportProperties(), get_object_vars($this));
-    $this->__construct($values);
-  }
-
-  /**
    * {@inheritdoc}
    */
   public static function createFromDataType($type) {
diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
index 6024061..ac6f18d 100644
--- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
+++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
@@ -611,27 +611,6 @@ public function targetBundle() {
     return $this->bundle;
   }
 
-  /*
-   * Implements the magic __sleep() method.
-   *
-   * Using the Serialize interface and serialize() / unserialize() methods
-   * breaks entity forms in PHP 5.4.
-   * @todo Investigate in https://drupal.org/node/2074253.
-   */
-  public function __sleep() {
-    // Only serialize properties from getExportProperties().
-    return array_keys(array_intersect_key($this->getExportProperties(), get_object_vars($this)));
-  }
-
-  /**
-   * Implements the magic __wakeup() method.
-   */
-  public function __wakeup() {
-    // Run the values from getExportProperties() through __construct().
-    $values = array_intersect_key($this->getExportProperties(), get_object_vars($this));
-    $this->__construct($values);
-  }
-
   /**
    * {@inheritdoc}
    */
