diff -u b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php --- b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -286,9 +286,14 @@ * 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, $this->entityTypeId); + // PHPUnit uses unserilalize() 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); + } } }