diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index 5033244..18e0260 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -7,10 +7,9 @@
 
 namespace Drupal\Core\Config\Entity;
 
-use Drupal\Component\Utility\String;
 use Drupal\Core\Entity\Entity;
-use Drupal\Core\Config\ConfigDuplicateUUIDException;
 use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Drupal\Core\Config\ConfigDuplicateUUIDException;
 
 /**
  * Defines a base configuration entity class.
@@ -126,8 +125,6 @@ public function set($property_name, $value) {
     }
 
     $this->{$property_name} = $value;
-
-    return $this;
   }
 
   /**
@@ -164,8 +161,6 @@ public function status() {
    */
   public function setSyncing($syncing) {
     $this->isSyncing = $syncing;
-
-    return $this;
   }
 
   /**
@@ -189,7 +184,7 @@ public function createDuplicate() {
   /**
    * Helper callback for uasort() to sort configuration entities by weight and label.
    */
-  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
+  public static function sort($a, $b) {
     $a_weight = isset($a->weight) ? $a->weight : 0;
     $b_weight = isset($b->weight) ? $b->weight : 0;
     if ($a_weight == $b_weight) {
@@ -236,14 +231,14 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
       ->execute();
     $matched_entity = reset($matching_entities);
     if (!empty($matched_entity) && ($matched_entity != $this->id())) {
-      throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
+      throw new ConfigDuplicateUUIDException(format_string('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
     }
 
     if (!$this->isNew()) {
       $original = $storage_controller->loadUnchanged($this->id());
       // Ensure that the UUID cannot be changed for an existing entity.
       if ($original && ($original->uuid() != $this->uuid())) {
-        throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
+        throw new ConfigDuplicateUUIDException(format_string('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
       }
     }
   }
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php
index 1f1c715..5aa737d 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php
@@ -28,21 +28,23 @@ public function getOriginalId();
    * @param string $id
    *   The new ID to set as original ID.
    *
-   * @return $this
+   * @return self
    */
   public function setOriginalId($id);
 
   /**
    * Enables the configuration entity.
    *
-   * @return $this
+   * @return \Drupal\Core\Config\Entity\ConfigEntityInterface
+   *   The configuration entity.
    */
   public function enable();
 
   /**
    * Disables the configuration entity.
    *
-   * @return $this
+   * @return \Drupal\Core\Config\Entity\ConfigEntityInterface
+   *   The configuration entity.
    */
   public function disable();
 
@@ -52,7 +54,8 @@ public function disable();
    * @param bool $status
    *   The status of the configuration entity.
    *
-   * @return $this
+   * @return \Drupal\Core\Config\Entity\ConfigEntityInterface
+   *   The class instance that this method is called on.
    */
   public function setStatus($status);
 
@@ -61,8 +64,6 @@ public function setStatus($status);
    *
    * @param bool $status
    *   The status of the sync flag.
-   *
-   * @return $this
    */
   public function setSyncing($status);
 
@@ -108,8 +109,6 @@ public function get($property_name);
    *   The name of the property that should be set.
    * @param mixed $value
    *   The value the property should be set to.
-   *
-   * @return $this
    */
   public function set($property_name, $value);
 
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
index ba016cb..82e5241 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
@@ -129,19 +129,12 @@
   protected $isDefaultRevision = TRUE;
 
   /**
-   * The typed data manager.
-   *
-   * @var \Drupal\Core\TypedData\TypedDataManager
-   */
-  protected $typedDataManager;
-
-  /**
    * Overrides Entity::__construct().
    */
   public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) {
     $this->entityTypeId = $entity_type;
     $this->bundle = $bundle ? $bundle : $this->entityTypeId;
-    $this->languages = $this->languageList(Language::STATE_ALL);
+    $this->languages = language_list(Language::STATE_ALL);
 
     foreach ($values as $key => $value) {
       // If the key matches an existing property set the value to the property
@@ -169,26 +162,6 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans
   }
 
   /**
-   * Wraps $this->languageList().
-   */
-  protected function languageList($flags = Language::STATE_CONFIGURABLE) {
-    return language_list($flags);
-  }
-
-  /**
-   * Returns the typed data manager.
-   *
-   * @return \Drupal\Core\TypedData\TypedDataManager
-   */
-  protected function typedDataManager() {
-    if (!$this->typedDataManager) {
-      $this->typedDataManager = \Drupal::typedDataManager();
-    }
-
-    return $this->typedDataManager;
-  }
-
-  /**
    * {@inheritdoc}
    */
   public function setNewRevision($value = TRUE) {
@@ -224,7 +197,8 @@ public function getRevisionId() {
    * {@inheritdoc}
    */
   public function isTranslatable() {
-    $bundles = $this->entityManager()->getBundleInfo($this->entityTypeId);
+    // @todo Inject the entity manager and retrieve bundle info from it.
+    $bundles = entity_get_bundles($this->entityTypeId);
     return !empty($bundles[$this->bundle()]['translatable']);
   }
 
@@ -265,14 +239,15 @@ public function setValue($value, $notify = TRUE) {
    * {@inheritdoc}
    */
   public function getString() {
-    return (string) $this->label();
+    return $this->label();
   }
 
   /**
    * {@inheritdoc}
    */
   public function validate() {
-    return $this->typedDataManager()->getValidator()->validate($this);
+    // @todo: Add the typed data manager as proper dependency.
+    return \Drupal::typedDataManager()->getValidator()->validate($this);
   }
 
   /**
@@ -358,7 +333,10 @@ public function __sleep() {
     $this->fieldDefinitions = NULL;
     $this->clearTranslationCache();
 
-    return parent::__sleep();
+    // Don't serialize the url generator.
+    $this->urlGenerator = NULL;
+
+    return array_keys(get_object_vars($this));
   }
 
 
@@ -366,7 +344,6 @@ public function __sleep() {
    * Magic __wakeup() implementation.
    */
   public function __wakeup() {
-    parent::__wakeup();
     $this->init();
   }
 
@@ -416,7 +393,7 @@ public function get($property_name) {
   protected function getTranslatedField($name, $langcode) {
     if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
       $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode)));
+      throw new \InvalidArgumentException(format_string($message, array('@langcode' => $this->activeLangcode)));
     }
     // Populate $this->fields to speed-up further look-ups and to keep track of
     // fields objects, possibly holding changes to field values.
@@ -549,13 +526,13 @@ public function isEmpty() {
   /**
    * {@inheritdoc}
    */
-  public function access($operation, AccountInterface $account = NULL) {
+  public function access($operation = 'view', AccountInterface $account = NULL) {
     if ($operation == 'create') {
-      return $this->entityManager()
+      return \Drupal::entityManager()
         ->getAccessController($this->entityTypeId)
         ->createAccess($this->bundle(), $account);
     }
-    return $this->entityManager()
+    return \Drupal::entityManager()
       ->getAccessController($this->entityTypeId)
       ->access($this, $operation, $this->activeLangcode, $account);
   }
@@ -567,7 +544,7 @@ public function language() {
     $language = NULL;
     if ($this->activeLangcode != Language::LANGCODE_DEFAULT) {
       if (!isset($this->languages[$this->activeLangcode])) {
-        $this->languages += $this->languageList(Language::STATE_ALL);
+        $this->languages += language_list(Language::STATE_ALL);
       }
       $language = $this->languages[$this->activeLangcode];
     }
@@ -617,7 +594,7 @@ public function onChange($name) {
     if ($name == 'langcode') {
       $this->setDefaultLangcode();
       if (isset($this->translations[$this->defaultLangcode])) {
-        $message = String::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
+        $message = format_string('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
         throw new \InvalidArgumentException($message);
       }
       $this->updateFieldLangcodes($this->defaultLangcode);
@@ -666,7 +643,7 @@ public function getTranslation($langcode) {
 
     if (empty($translation)) {
       $message = 'Invalid translation language (@langcode) specified.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
+      throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode)));
     }
 
     return $translation;
@@ -731,14 +708,14 @@ public function hasTranslation($langcode) {
   public function addTranslation($langcode, array $values = array()) {
     if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) {
       $message = 'Invalid translation language (@langcode) specified.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
+      throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode)));
     }
 
     // Instantiate a new empty entity so default values will be populated in the
     // specified language.
     $entity_type = $this->getEntityType();
     $default_values = array($entity_type->getKey('bundle') => $this->bundle, 'langcode' => $langcode);
-    $entity = $this->entityManager()
+    $entity = \Drupal::entityManager()
       ->getStorageController($this->getEntityTypeId())
       ->create($default_values);
 
@@ -776,7 +753,7 @@ public function removeTranslation($langcode) {
     }
     else {
       $message = 'The specified translation (@langcode) cannot be removed.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
+      throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode)));
     }
   }
 
@@ -918,7 +895,7 @@ public function __unset($name) {
   public function createDuplicate() {
     if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
       $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.';
-      throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode)));
+      throw new \InvalidArgumentException(format_string($message, array('@langcode' => $this->activeLangcode)));
     }
 
     $duplicate = clone $this;
@@ -927,7 +904,8 @@ public function createDuplicate() {
 
     // Check if the entity type supports UUIDs and generate a new one if so.
     if ($entity_type->hasKey('uuid')) {
-      $duplicate->{$entity_type->getKey('uuid')}->value = $this->uuidGenerator()->generate();
+      // @todo Inject the UUID service into the Entity class once possible.
+      $duplicate->{$entity_type->getKey('uuid')}->value = \Drupal::service('uuid')->generate();
     }
 
     // Check whether the entity type supports revisions and initialize it if so.
@@ -975,8 +953,9 @@ public function __clone() {
   public function label() {
     $label = NULL;
     $entity_type = $this->getEntityType();
-    if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) {
-      $label = call_user_func($label_callback, $this);
+    // @todo Convert to is_callable() and call_user_func().
+    if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) {
+      $label = $label_callback($this);
     }
     elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) {
       $label = $this->{$label_key}->value;
diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php
index 8fd3a62..5d70510 100644
--- a/core/lib/Drupal/Core/Entity/Entity.php
+++ b/core/lib/Drupal/Core/Entity/Entity.php
@@ -7,14 +7,13 @@
 
 namespace Drupal\Core\Entity;
 
-use Drupal\Core\DependencyInjection\DependencySerialization;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Defines a base entity class.
  */
-abstract class Entity extends DependencySerialization implements EntityInterface {
+abstract class Entity implements EntityInterface {
 
   /**
    * The language code of the entity's default language.
@@ -24,20 +23,6 @@
   public $langcode = Language::LANGCODE_NOT_SPECIFIED;
 
   /**
-   * The entity manager.
-   *
-   * @var \Drupal\Core\Entity\EntityManagerInterface
-   */
-  protected $entityManager;
-
-  /**
-   * The UUID generator.
-   *
-   * @var \Drupal\Component\Uuid\UuidInterface
-   */
-  protected $uuidGenerator;
-
-  /**
    * The entity type.
    *
    * @var string
@@ -76,39 +61,6 @@ public function __construct(array $values, $entity_type) {
   }
 
   /**
-   * Wraps language_load().
-   */
-  protected function languageLoad($langcode) {
-    return language_load($langcode);
-  }
-
-  /**
-   * Returns the entity manager.
-   *
-   * @return \Drupal\Core\Entity\EntityManagerInterface
-   */
-  protected function entityManager() {
-    if (!$this->entityManager) {
-      $this->entityManager = \Drupal::entityManager();
-    }
-
-    return $this->entityManager;
-  }
-
-  /**
-   * Returns the UUID generator.
-   *
-   * @return \Drupal\Component\Uuid\UuidInterface
-   */
-  protected function uuidGenerator() {
-    if (!$this->uuidGenerator) {
-      $this->uuidGenerator = \Drupal::service('uuid');
-    }
-
-    return $this->uuidGenerator;
-  }
-
-  /**
    * {@inheritdoc}
    */
   public function id() {
@@ -134,8 +86,6 @@ public function isNew() {
    */
   public function enforceIsNew($value = TRUE) {
     $this->enforceIsNew = $value;
-
-    return $this;
   }
 
   /**
@@ -158,8 +108,9 @@ public function bundle() {
   public function label() {
     $label = NULL;
     $entity_type = $this->getEntityType();
-    if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) {
-      $label = call_user_func($label_callback, $this);
+    // @todo Convert to is_callable() and call_user_func().
+    if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) {
+      $label = $label_callback($this);
     }
     elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) {
       $label = $this->{$label_key};
@@ -187,7 +138,7 @@ public function urlInfo($rel = 'canonical') {
       $bundle = $this->bundle();
       // A bundle-specific callback takes precedence over the generic one for
       // the entity type.
-      $bundles = $this->entityManager()->getBundleInfo($this->getEntityTypeId());
+      $bundles = \Drupal::entityManager()->getBundleInfo($this->getEntityTypeId());
       if (isset($bundles[$bundle]['uri_callback'])) {
         $uri_callback = $bundles[$bundle]['uri_callback'];
       }
@@ -197,8 +148,9 @@ public function urlInfo($rel = 'canonical') {
 
       // Invoke the callback to get the URI. If there is no callback, use the
       // default URI format.
-      if (isset($uri_callback) && is_callable($uri_callback)) {
-        $uri = call_user_func($uri_callback, $this);
+      // @todo Convert to is_callable() and call_user_func().
+      if (isset($uri_callback) && function_exists($uri_callback)) {
+        $uri = $uri_callback($this);
       }
       else {
         return array();
@@ -295,13 +247,13 @@ public function uriRelationships() {
   /**
    * {@inheritdoc}
    */
-  public function access($operation, AccountInterface $account = NULL) {
+  public function access($operation = 'view', AccountInterface $account = NULL) {
     if ($operation == 'create') {
-      return $this->entityManager()
+      return \Drupal::entityManager()
         ->getAccessController($this->entityTypeId)
         ->createAccess($this->bundle(), $account);
     }
-    return $this->entityManager()
+    return \Drupal::entityManager()
       ->getAccessController($this->entityTypeId)
       ->access($this, $operation, Language::LANGCODE_DEFAULT, $account);
   }
@@ -310,7 +262,7 @@ public function access($operation, AccountInterface $account = NULL) {
    * {@inheritdoc}
    */
   public function language() {
-    $language = $this->languageLoad($this->langcode);
+    $language = language_load($this->langcode);
     if (!$language) {
       // Make sure we return a proper language object.
       $language = new Language(array('id' => Language::LANGCODE_NOT_SPECIFIED));
@@ -322,7 +274,7 @@ public function language() {
    * {@inheritdoc}
    */
   public function save() {
-    return $this->entityManager()->getStorageController($this->entityTypeId)->save($this);
+    return \Drupal::entityManager()->getStorageController($this->entityTypeId)->save($this);
   }
 
   /**
@@ -330,7 +282,7 @@ public function save() {
    */
   public function delete() {
     if (!$this->isNew()) {
-      $this->entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this));
+      \Drupal::entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this));
     }
   }
 
@@ -344,7 +296,8 @@ public function createDuplicate() {
 
     // Check if the entity type supports UUIDs and generate a new one if so.
     if ($entity_type->hasKey('uuid')) {
-      $duplicate->{$entity_type->getKey('uuid')} = $this->uuidGenerator()->generate();
+      // @todo Inject the UUID service into the Entity class once possible.
+      $duplicate->{$entity_type->getKey('uuid')} = \Drupal::service('uuid')->generate();
     }
     return $duplicate;
   }
@@ -353,7 +306,7 @@ public function createDuplicate() {
    * {@inheritdoc}
    */
   public function getEntityType() {
-    return $this->entityManager()->getDefinition($this->getEntityTypeId());
+    return \Drupal::entityManager()->getDefinition($this->getEntityTypeId());
   }
 
   /**
@@ -391,7 +344,6 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr
    * {@inheritdoc}
    */
   public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
-    /** @var self[] $entities */
     foreach ($entities as $entity) {
       $entity->onSaveOrDelete();
     }
@@ -423,8 +375,8 @@ protected function onSaveOrDelete() {
     }
 
     foreach ($referenced_entities as $entity_type => $entities) {
-      if ($this->entityManager()->hasController($entity_type, 'view_builder')) {
-        $this->entityManager()->getViewBuilder($entity_type)->resetCache($entities);
+      if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) {
+        \Drupal::entityManager()->getViewBuilder($entity_type)->resetCache($entities);
       }
     }
   }
@@ -442,4 +394,14 @@ protected function urlGenerator() {
     return $this->urlGenerator;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function __sleep() {
+    // Don't serialize the url generator.
+    $this->urlGenerator = NULL;
+
+    return array_keys(get_object_vars($this));
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php
index 769a85e..057727b 100644
--- a/core/lib/Drupal/Core/Entity/EntityInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityInterface.php
@@ -65,8 +65,6 @@ public function isNew();
    *   (optional) Whether the entity should be forced to be new. Defaults to
    *   TRUE.
    *
-   * @return self
-   *
    * @see \Drupal\Core\Entity\EntityInterface::isNew()
    */
   public function enforceIsNew($value = TRUE);
diff --git a/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php b/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php
index 581e79c..452b602 100644
--- a/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php
+++ b/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php
@@ -63,7 +63,7 @@ public function set($property_name, $value, $notify = TRUE);
    * @param bool $include_computed
    *   If set to TRUE, computed properties are included. Defaults to FALSE.
    *
-   * @return \Drupal\Core\TypedData\TypedDataInterface[]
+   * @return array
    *   An array of property objects implementing the TypedDataInterface, keyed
    *   by property name.
    */
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 6f341ad..1bca18b 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -199,7 +199,7 @@ function _block_get_renderable_region($list = array()) {
     $settings = $block->get('settings');
     if ($not_cacheable || in_array($settings['cache'], array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM))) {
       // Non-cached blocks get built immediately.
-      if ($block->access('view')) {
+      if ($block->access()) {
         $build[$key] = entity_view($block, 'block');
       }
     }
@@ -378,7 +378,7 @@ function block_load($entity_id) {
 function _block_get_renderable_block($element) {
   $block = $element['#block'];
   // Don't bother to build blocks that aren't accessible.
-  if ($element['#access'] = $block->access('view')) {
+  if ($element['#access'] = $block->access()) {
     $element += entity_view($block, 'block');
   }
   return $element;
diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php
index e44d028..cb49cac 100644
--- a/core/modules/block/lib/Drupal/block/Entity/Block.php
+++ b/core/modules/block/lib/Drupal/block/Entity/Block.php
@@ -10,7 +10,6 @@
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\block\BlockPluginBag;
 use Drupal\block\BlockInterface;
-use Drupal\Core\Config\Entity\ConfigEntityInterface;
 use Drupal\Core\Config\Entity\EntityWithPluginBagInterface;
 
 /**
@@ -149,7 +148,7 @@ public function getExportProperties() {
   /**
    * Sorts active blocks by weight; sorts inactive blocks by name.
    */
-  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
+  public static function sort($a, $b) {
     // Separate enabled from disabled.
     $status = $b->get('status') - $a->get('status');
     if ($status) {
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php
index 7ec5e86..55ded74 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php
@@ -97,4 +97,14 @@ public function testStorageControllerMethods() {
     }
   }
 
+  /**
+   * Tests getOriginalId() and setOriginalId().
+   */
+  protected function testGetOriginalId() {
+    $entity = $this->storage->create(array());
+    $id = $this->randomName();
+    $this->assertIdentical(spl_object_hash($entity->setOriginalId($id)), spl_object_hash($entity));
+    $this->assertIdentical($entity->getOriginalId(), $id);
+  }
+
 }
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php
index 8074ab3..029a7ac 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php
@@ -9,7 +9,6 @@
 
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\config_test\ConfigTestInterface;
-use Drupal\Core\Config\Entity\ConfigEntityInterface;
 
 /**
  * Defines the ConfigTest configuration entity.
@@ -94,7 +93,7 @@ public function getExportProperties() {
   /**
    * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
    */
-  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
+  public static function sort($a, $b) {
     \Drupal::state()->set('config_entity_sort', TRUE);
     return parent::sort($a, $b);
   }
diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php
index d07030a..6705f03 100644
--- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php
+++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php
@@ -8,7 +8,6 @@
 namespace Drupal\entity;
 
 use Drupal\Core\Config\Entity\ConfigEntityBase;
-use Drupal\Core\Config\Entity\ConfigEntityInterface;
 
 /**
  * Base class for config entity types that hold settings for form and view modes.
@@ -61,9 +60,7 @@
   /**
    * {@inheritdoc}
    */
-  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
-    /** @var \Drupal\entity\EntityDisplayModeInterface $a */
-    /** @var \Drupal\entity\EntityDisplayModeInterface $b */
+  public static function sort($a, $b) {
     // Sort by the type of entity the view mode is used for.
     $a_type = $a->getTargetType();
     $b_type = $b->getTargetType();
diff --git a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php
index 947c878..36444e0 100644
--- a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php
+++ b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php
@@ -8,7 +8,6 @@
 namespace Drupal\search\Entity;
 
 use Drupal\Core\Config\Entity\ConfigEntityBase;
-use Drupal\Core\Config\Entity\ConfigEntityInterface;
 use Drupal\Core\Config\Entity\EntityWithPluginBagInterface;
 use Drupal\Core\Entity\EntityStorageControllerInterface;
 use Drupal\Component\Plugin\ConfigurablePluginInterface;
@@ -214,7 +213,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
   /**
    * {@inheritdoc}
    */
-  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
+  public static function sort($a, $b) {
     /** @var $a \Drupal\search\SearchPageInterface */
     /** @var $b \Drupal\search\SearchPageInterface */
     $a_status = (int) $a->status();
diff --git a/core/modules/system/lib/Drupal/system/Entity/Action.php b/core/modules/system/lib/Drupal/system/Entity/Action.php
index 85cab8b..93b38f1 100644
--- a/core/modules/system/lib/Drupal/system/Entity/Action.php
+++ b/core/modules/system/lib/Drupal/system/Entity/Action.php
@@ -8,7 +8,6 @@
 namespace Drupal\system\Entity;
 
 use Drupal\Core\Config\Entity\ConfigEntityBase;
-use Drupal\Core\Config\Entity\ConfigEntityInterface;
 use Drupal\Core\Config\Entity\EntityWithPluginBagInterface;
 use Drupal\system\ActionConfigEntityInterface;
 use Drupal\Core\Action\ActionBag;
@@ -132,9 +131,7 @@ public function getType() {
   /**
    * {@inheritdoc}
    */
-  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
-    /** @var \Drupal\system\ActionConfigEntityInterface $a */
-    /** @var \Drupal\system\ActionConfigEntityInterface $b */
+  public static function sort($a, $b) {
     $a_type = $a->getType();
     $b_type = $b->getType();
     if ($a_type != $b_type) {
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLabelTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLabelTest.php
new file mode 100644
index 0000000..097c7bc
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLabelTest.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\system\Tests\Entity\EntityLabelTest.
+ */
+
+namespace Drupal\system\Tests\Entity;
+
+/**
+ * Tests entity properties.
+ */
+class EntityLabelTest extends EntityUnitTestBase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Entity label',
+      'description' => 'Tests entity labels.',
+      'group' => 'Entity API',
+    );
+  }
+
+  /**
+   * Tests label key and label callback of an entity.
+   */
+  function testEntityLabel() {
+    $entity_types = array(
+      'entity_test_no_label',
+      'entity_test_label',
+      'entity_test_label_callback',
+    );
+
+    $values = array(
+      'name' => $this->randomName(),
+    );
+    foreach ($entity_types as $entity_type) {
+      $entity = entity_create($entity_type, $values);
+      $label = $entity->label();
+
+      switch ($entity_type) {
+        case 'entity_test_no_label':
+          $this->assertFalse($label, 'Entity with no label property or callback returned FALSE.');
+          break;
+
+        case 'entity_test_label':
+          $this->assertEqual($label, $entity->name->value, 'Entity with label key returned correct label.');
+          break;
+
+        case 'entity_test_label_callback':
+          $this->assertEqual($label, 'label callback ' . $entity->name->value, 'Entity with label callback returned correct label.');
+          break;
+      }
+    }
+  }
+}
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index d7a08fc..bfc73b5 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -318,6 +318,19 @@ function entity_test_entity_test_insert($entity) {
 }
 
 /**
+ * Entity label callback.
+ *
+ * @param $entity
+ *   The entity object.
+ *
+ * @return
+ *   The label of the entity prefixed with "label callback".
+ */
+function entity_test_label_callback($entity) {
+  return 'label callback ' . $entity->name->value;
+}
+
+/**
  * Implements hook_entity_field_access().
  *
  * @see \Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess()
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
deleted file mode 100644
index d7271d9..0000000
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
+++ /dev/null
@@ -1,233 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest.
- */
-
-namespace Drupal\Tests\Core\Config\Entity;
-
-use Drupal\Core\DependencyInjection\ContainerBuilder;
-use Drupal\Tests\UnitTestCase;
-
-/**
- * @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase
- *
- * @group Drupal
- */
-class ConfigEntityBaseUnitTest extends UnitTestCase {
-
-  /**
-   * The entity under test.
-   *
-   * @var \Drupal\Core\Config\Entity\ConfigEntityBase|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entity;
-
-  /**
-   * The entity info used for testing..
-   *
-   * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entityInfo;
-
-  /**
-   * The entity manager used for testing.
-   *
-   * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entityManager;
-
-  /**
-   * The type of the entity under test.
-   *
-   * @var string
-   */
-  protected $entityType;
-
-  /**
-   * The UUID generator used for testing.
-   *
-   * @var \Drupal\Component\Uuid\UuidInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $uuid;
-
-  /**
-   * {@inheritdoc}
-   */
-  public static function getInfo() {
-    return array(
-      'description' => '',
-      'name' => '\Drupal\Core\Config\Entity\ConfigEntityBase unit test',
-      'group' => 'Entity',
-    );
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function setUp() {
-    $values = array();
-    $this->entityType = $this->randomName();
-
-    $this->entityInfo = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
-
-    $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
-    $this->entityManager->expects($this->any())
-      ->method('getDefinition')
-      ->with($this->entityType)
-      ->will($this->returnValue($this->entityInfo));
-
-    $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
-
-    $container = new ContainerBuilder();
-    $container->set('entity.manager', $this->entityManager);
-    $container->set('uuid', $this->uuid);
-    \Drupal::setContainer($container);
-
-    $this->entity = $this->getMockBuilder('\Drupal\Core\Config\Entity\ConfigEntityBase')
-      ->setConstructorArgs(array($values, $this->entityType))
-      ->setMethods(array('languageLoad'))
-      ->getMock();
-    $this->entity->expects($this->any())
-      ->method('languageLoad')
-      ->will($this->returnValue(NULL));
-  }
-
-  /**
-   * @covers ::setOriginalId
-   * @covers ::getOriginalId
-   */
-  public function testGetOriginalId() {
-    $id = $this->randomName();
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setOriginalId($id)));
-    $this->assertSame($id, $this->entity->getOriginalId());
-  }
-
-  /**
-   * @covers ::isNew
-   */
-  public function testIsNew() {
-    $this->assertFalse($this->entity->isNew());
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew()));
-    $this->assertTrue($this->entity->isNew());
-    $this->entity->enforceIsNew(FALSE);
-    $this->assertFalse($this->entity->isNew());
-  }
-
-  /**
-   * @covers ::set
-   * @covers ::get
-   */
-  public function testGet() {
-    $name = $this->randomName();
-    $value = $this->randomName();
-    $this->assertNull($this->entity->get($name));
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->set($name, $value)));
-    $this->assertSame($value, $this->entity->get($name));
-  }
-
-  /**
-   * @covers ::setStatus
-   * @covers ::status
-   */
-  public function testSetStatus() {
-    $this->assertTrue($this->entity->status());
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setStatus(FALSE)));
-    $this->assertFalse($this->entity->status());
-    $this->entity->setStatus(TRUE);
-    $this->assertTrue($this->entity->status());
-  }
-
-  /**
-   * @covers ::enable
-   * @depends testSetStatus
-   */
-  public function testEnable() {
-    $this->entity->setStatus(FALSE);
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enable()));
-    $this->assertTrue($this->entity->status());
-  }
-
-  /**
-   * @covers ::disable
-   * @depends testSetStatus
-   */
-  public function testDisable() {
-    $this->entity->setStatus(TRUE);
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->disable()));
-    $this->assertFalse($this->entity->status());
-  }
-
-  /**
-   * @covers ::setSyncing
-   * @covers ::isSyncing
-   */
-  public function testIsSyncing() {
-    $this->assertFalse($this->entity->isSyncing());
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setSyncing(TRUE)));
-    $this->assertTrue($this->entity->isSyncing());
-    $this->entity->setSyncing(FALSE);
-    $this->assertFalse($this->entity->isSyncing());
-  }
-
-  /**
-   * @covers ::createDuplicate
-   */
-  public function testCreateDuplicate() {
-    $this->entityInfo->expects($this->once())
-      ->method('getKey')
-      ->with('id')
-      ->will($this->returnValue('id'));
-
-    $this->entity->setOriginalId('foo');
-    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $duplicate */
-    $duplicate = $this->entity->createDuplicate();
-    $this->assertInstanceOf('\Drupal\Core\Entity\Entity', $duplicate);
-    $this->assertNotSame(spl_object_hash($this->entity), spl_object_hash($duplicate));
-    $this->assertNull($duplicate->id());
-    $this->assertNull($duplicate->getOriginalId());
-    $this->assertNull($duplicate->uuid());
-  }
-
-  /**
-   * @covers ::sort
-   */
-  public function testSort() {
-    $this->entityManager->expects($this->any())
-      ->method('getDefinition')
-      ->with($this->entityType)
-      ->will($this->returnValue(array(
-        'entity_keys' => array(
-          'label' => 'label',
-        ),
-      )));
-    $entity_a = $this->entity;
-    $entity_a->label = 'foo';
-    $entity_b = clone $this->entity;
-    $entity_b->label = 'bar';
-    $list = array($entity_a, $entity_b);
-    // Suppress errors because of https://bugs.php.net/bug.php?id=50688.
-    @usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort');
-    $this->assertSame(spl_object_hash($entity_b), spl_object_hash($list[0]));
-    $entity_a->weight = 0;
-    $entity_b->weight = 1;
-    // Suppress errors because of https://bugs.php.net/bug.php?id=50688.
-    @usort($list, array($entity_a, 'sort'));
-    $this->assertSame(spl_object_hash($entity_a), spl_object_hash($list[0]));
-  }
-
-  /**
-   * @covers ::getExportProperties
-   */
-  public function testGetExportProperties() {
-    $properties = $this->entity->getExportProperties();
-    $this->assertInternalType('array', $properties);
-    $class_info = new \ReflectionClass($this->entity);
-    foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
-      $name = $property->getName();
-      $this->assertArrayHasKey($name, $properties);
-      $this->assertSame($this->entity->get($name), $properties[$name]);
-    }
-  }
-}
diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
deleted file mode 100644
index 789306b..0000000
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
+++ /dev/null
@@ -1,326 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest.
- */
-
-namespace Drupal\Tests\Core\Entity;
-
-use Drupal\Core\DependencyInjection\ContainerBuilder;
-use Drupal\Tests\UnitTestCase;
-
-/**
- * @coversDefaultClass \Drupal\Core\Entity\ContentEntityBase
- *
- * @group Drupal
- */
-class ContentEntityBaseUnitTest extends UnitTestCase {
-
-  /**
-   * The bundle of the entity under test.
-   *
-   * @var string
-   */
-  protected $bundle;
-
-  /**
-   * The entity under test.
-   *
-   * @var \Drupal\Core\Entity\ContentEntityBase|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entity;
-
-  /**
-   * The entity info used for testing..
-   *
-   * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entityInfo;
-
-  /**
-   * The entity manager used for testing.
-   *
-   * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entityManager;
-
-  /**
-   * The type of the entity under test.
-   *
-   * @var string
-   */
-  protected $entityType;
-
-  /**
-   * The typed data manager used for testing.
-   *
-   * @var \Drupal\Core\TypedData\TypedDataManager|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $typedDataManager;
-
-  /**
-   * The UUID generator used for testing.
-   *
-   * @var \Drupal\Component\Uuid\UuidInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $uuid;
-
-  /**
-   * {@inheritdoc}
-   */
-  public static function getInfo() {
-    return array(
-      'description' => '',
-      'name' => '\Drupal\Core\Entity\ContentEntityBase unit test',
-      'group' => 'Entity',
-    );
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function setUp() {
-    $values = array();
-    $this->entityType = $this->randomName();
-    $this->bundle = $this->randomName();
-
-    $this->entityInfo = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
-
-    $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
-    $this->entityManager->expects($this->any())
-      ->method('getDefinition')
-      ->with($this->entityType)
-      ->will($this->returnValue($this->entityInfo));
-    $this->entityManager->expects($this->any())
-      ->method('getFieldDefinitions')
-      ->with($this->entityType, $this->bundle)
-      ->will($this->returnValue(array(
-        'id' => array(
-          'type' => 'integer_field',
-        ),
-      )));
-
-    $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
-
-    $this->typedDataManager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager')
-      ->disableOriginalConstructor()
-      ->getMock();
-
-    $container = new ContainerBuilder();
-    $container->set('entity.manager', $this->entityManager);
-    $container->set('uuid', $this->uuid);
-    $container->set('typed_data_manager', $this->typedDataManager);
-    \Drupal::setContainer($container);
-
-    $this->entity = $this->getMockBuilder('\Drupal\Core\Entity\ContentEntityBase')
-      ->setConstructorArgs(array($values, $this->entityType, $this->bundle))
-      ->setMethods(array('languageList', 'languageLoad'))
-      ->getMockForAbstractClass();
-    $this->entity->expects($this->any())
-      ->method('languageList')
-      ->will($this->returnValue(array()));
-    $this->entity->expects($this->any())
-      ->method('languageLoad')
-      ->will($this->returnValue(NULL));
-  }
-
-  /**
-   * @covers ::isNewRevision
-   * @covers ::setNewRevision
-   */
-  public function testIsNewRevision() {
-    $this->entityInfo->expects($this->at(0))
-      ->method('hasKey')
-      ->with('revision')
-      ->will($this->returnValue(FALSE));
-    $this->entityInfo->expects($this->at(1))
-      ->method('hasKey')
-      ->with('revision')
-      ->will($this->returnValue(TRUE));
-
-    $this->assertFalse($this->entity->isNewRevision());
-    $this->assertTrue($this->entity->isNewRevision());
-    $this->entity->setNewRevision(TRUE);
-    $this->assertTRUE($this->entity->isNewRevision());
-  }
-
-  /**
-   * @covers ::isDefaultRevision
-   */
-  public function testIsDefaultRevision() {
-    // The default value is TRUE.
-    $this->assertTrue($this->entity->isDefaultRevision());
-    // We override the value, but it does not affect this call.
-    $this->assertTrue($this->entity->isDefaultRevision(FALSE));
-    // The last call changed the return value for this call.
-    $this->assertFalse($this->entity->isDefaultRevision());
-  }
-
-  /**
-   * @covers ::getRevisionId
-   */
-  public function testGetRevisionId() {
-    $this->assertNull($this->entity->getRevisionId());
-  }
-
-  /**
-   * @covers ::isTranslatable
-   */
-  public function testIsTranslatable() {
-    $this->entityManager->expects($this->at(0))
-      ->method('getBundleInfo')
-      ->with($this->entityType)
-      ->will($this->returnValue(array(
-        $this->bundle => array(
-          'translatable' => TRUE,
-        ),
-      )));
-    $this->assertTrue($this->entity->isTranslatable());
-    $this->assertFalse($this->entity->isTranslatable());
-  }
-
-  /**
-   * @covers ::preSaveRevision
-   */
-  public function testPreSaveRevision() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $record = new \stdClass();
-    $this->entity->preSaveRevision($storage, $record);
-  }
-
-  /**
-   * @covers ::getString
-   */
-  public function testGetString() {
-    $label = $this->randomName();
-    /** @var \Drupal\Core\Entity\ContentEntityBase|\PHPUnit_Framework_MockObject_MockObject $entity */
-    $entity = $this->getMockBuilder('\Drupal\Core\Entity\ContentEntityBase')
-      ->setMethods(array('label'))
-      ->disableOriginalConstructor()
-      ->getMockForAbstractClass();
-    $entity->expects($this->once())
-      ->method('label')
-      ->will($this->returnValue($label));
-
-    $this->assertSame($label, $entity->getString());
-  }
-
-  /**
-   * @covers ::validate
-   */
-  public function testValidate() {
-    $validator = $this->getMock('\Symfony\Component\Validator\ValidatorInterface');
-    /** @var \Symfony\Component\Validator\ConstraintViolationList|\PHPUnit_Framework_MockObject_MockObject $empty_violation_list */
-    $empty_violation_list = $this->getMockBuilder('\Symfony\Component\Validator\ConstraintViolationList')
-      ->setMethods(NULL)
-      ->getMock();
-    $non_empty_violation_list = clone $empty_violation_list;
-    $violation = $this->getMock('\Symfony\Component\Validator\ConstraintViolationInterface');
-    $non_empty_violation_list->add($violation);
-    $validator->expects($this->at(0))
-      ->method('validate')
-      ->with($this->entity)
-      ->will($this->returnValue($empty_violation_list));
-    $validator->expects($this->at(1))
-      ->method('validate')
-      ->with($this->entity)
-      ->will($this->returnValue($non_empty_violation_list));
-    $this->typedDataManager->expects($this->exactly(2))
-      ->method('getValidator')
-      ->will($this->returnValue($validator));
-    $this->assertSame(0, count($this->entity->validate()));
-    $this->assertSame(1, count($this->entity->validate()));
-  }
-
-  /**
-   * @covers ::getConstraints
-   */
-  public function testGetConstraints() {
-    $this->assertInternalType('array', $this->entity->getConstraints());
-  }
-
-  /**
-   * @covers ::getName
-   */
-  public function testGetName() {
-    $this->assertNull($this->entity->getName());
-  }
-
-  /**
-   * @covers ::getRoot
-   */
-  public function testGetRoot() {
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->getRoot()));
-  }
-
-  /**
-   * @covers ::getPropertyPath
-   */
-  public function testGetPropertyPath() {
-    $this->assertSame('', $this->entity->getPropertyPath());
-  }
-
-  /**
-   * @covers ::getParent
-   */
-  public function testGetParent() {
-    $this->assertNull($this->entity->getParent());
-  }
-
-  /**
-   * @covers ::setContext
-   */
-  public function testSetContext() {
-    $name = $this->randomName();
-    $parent = $this->getMock('\Drupal\Core\TypedData\TypedDataInterface');
-    $this->entity->setContext($name, $parent);
-  }
-
-  /**
-   * @covers ::bundle
-   */
-  public function testBundle() {
-    $this->assertSame($this->bundle, $this->entity->bundle());
-  }
-
-  /**
-   * @covers ::access
-   */
-  public function testAccess() {
-    $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface');
-    $operation = $this->randomName();
-    $access->expects($this->at(0))
-      ->method('access')
-      ->with($this->entity, $operation)
-      ->will($this->returnValue(TRUE));
-    $access->expects($this->at(1))
-      ->method('createAccess')
-      ->will($this->returnValue(TRUE));
-    $this->entityManager->expects($this->exactly(2))
-      ->method('getAccessController')
-      ->will($this->returnValue($access));
-    $this->assertTrue($this->entity->access($operation));
-    $this->assertTrue($this->entity->access('create'));
-  }
-
-  /**
-   * @covers ::label
-   */
-  public function testLabel() {
-    // Make a mock with one method that we use as the entity's uri_callback. We
-    // check that it is called, and that the entity's label is the callback's
-    // return value.
-    $callback_label = $this->randomName();
-    $callback_container = $this->getMock(get_class());
-    $callback_container->expects($this->once())
-      ->method(__FUNCTION__)
-      ->will($this->returnValue($callback_label));
-    $this->entityInfo->expects($this->once())
-      ->method('getLabelCallback')
-      ->will($this->returnValue(array($callback_container, __FUNCTION__)));
-
-    $this->assertSame($callback_label, $this->entity->label());
-  }
-}
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
deleted file mode 100644
index a467a90..0000000
--- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
+++ /dev/null
@@ -1,332 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\Core\Entity\EntityUnitTest.
- */
-
-namespace Drupal\Tests\Core\Entity;
-
-use Drupal\Core\DependencyInjection\ContainerBuilder;
-use Drupal\Tests\UnitTestCase;
-
-/**
- * @coversDefaultClass \Drupal\Core\Entity\Entity
- *
- * @group Drupal
- */
-class EntityUnitTest extends UnitTestCase {
-
-  /**
-   * The entity under test.
-   *
-   * @var \Drupal\Core\Entity\Entity|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entity;
-
-  /**
-   * The entity info used for testing..
-   *
-   * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entityInfo;
-
-  /**
-   * The entity manager used for testing.
-   *
-   * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $entityManager;
-
-  /**
-   * The ID of the type of the entity under test.
-   *
-   * @var string
-   */
-  protected $entityTypeId;
-
-  /**
-   * The route provider used for testing.
-   *
-   * @var \Drupal\Core\Routing\RouteProvider|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $routeProvider;
-
-  /**
-   * The UUID generator used for testing.
-   *
-   * @var \Drupal\Component\Uuid\UuidInterface|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $uuid;
-
-  /**
-   * {@inheritdoc}
-   */
-  public static function getInfo() {
-    return array(
-      'description' => '',
-      'name' => '\Drupal\Core\Entity\Entity unit test',
-      'group' => 'Entity',
-    );
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function setUp() {
-    $values = array();
-    $this->entityTypeId = $this->randomName();
-
-    $this->entityInfo = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
-
-    $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
-    $this->entityManager->expects($this->any())
-      ->method('getDefinition')
-      ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityInfo));
-
-    $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
-
-    $container = new ContainerBuilder();
-    $container->set('entity.manager', $this->entityManager);
-    $container->set('uuid', $this->uuid);
-    \Drupal::setContainer($container);
-
-    $this->entity = $this->getMockBuilder('\Drupal\Core\Entity\Entity')
-      ->setConstructorArgs(array($values, $this->entityTypeId))
-      ->setMethods(array('languageLoad'))
-      ->getMock();
-    $this->entity->expects($this->any())
-      ->method('languageLoad')
-      ->will($this->returnValue(NULL));
-  }
-
-  /**
-   * @covers ::id
-   */
-  public function testId() {
-    // @todo How to test this?
-    $this->assertNull($this->entity->id());
-  }
-
-  /**
-   * @covers ::uuid
-   */
-  public function testUuid() {
-    // @todo How to test this?
-    $this->assertNull($this->entity->uuid());
-  }
-
-  /**
-   * @covers ::isNew
-   */
-  public function testIsNew() {
-    // @todo How to test this?
-    $this->assertInternalType('bool', $this->entity->isNew());
-  }
-
-  /**
-   * @covers ::enforceIsNew
-   */
-  public function testEnforceIsNew() {
-    $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew()));
-  }
-
-  /**
-   * @covers ::getEntityType
-   */
-  public function testGetEntityType() {
-    $this->assertInstanceOf('\Drupal\Core\Entity\EntityTypeInterface', $this->entity->getEntityType());
-  }
-
-  /**
-   * @covers ::bundle
-   */
-  public function testBundle() {
-    $this->assertSame($this->entityTypeId, $this->entity->bundle());
-  }
-
-  /**
-   * @covers ::label
-   */
-  public function testLabel() {
-    // Make a mock with one method that we use as the entity's uri_callback. We
-    // check that it is called, and that the entity's label is the callback's
-    // return value.
-    $callback_label = $this->randomName();
-    $property_label = $this->randomName();
-    $callback_container = $this->getMock(get_class());
-    $callback_container->expects($this->once())
-      ->method(__FUNCTION__)
-      ->will($this->returnValue($callback_label));
-    $this->entityInfo->expects($this->at(0))
-      ->method('getLabelCallback')
-      ->will($this->returnValue(array($callback_container, __FUNCTION__)));
-    $this->entityInfo->expects($this->at(1))
-      ->method('getLabelCallback')
-      ->will($this->returnValue(NULL));
-    $this->entityInfo->expects($this->at(2))
-      ->method('getKey')
-      ->with('label')
-      ->will($this->returnValue('label'));
-
-    // Set a dummy property on the entity under test to test that the label can
-    // be returned form a property if there is no callback.
-    $this->entityManager->expects($this->at(1))
-      ->method('getDefinition')
-      ->with($this->entityTypeId)
-      ->will($this->returnValue(array(
-        'entity_keys' => array(
-          'label' => 'label',
-        ),
-      )));
-    $this->entity->label = $property_label;
-
-    $this->assertSame($callback_label, $this->entity->label());
-    $this->assertSame($property_label, $this->entity->label());
-  }
-
-  /**
-   * @covers ::access
-   */
-  public function testAccess() {
-    $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface');
-    $operation = $this->randomName();
-    $access->expects($this->at(0))
-      ->method('access')
-      ->with($this->entity, $operation)
-      ->will($this->returnValue(TRUE));
-    $access->expects($this->at(1))
-      ->method('createAccess')
-      ->will($this->returnValue(TRUE));
-    $this->entityManager->expects($this->exactly(2))
-      ->method('getAccessController')
-      ->will($this->returnValue($access));
-    $this->assertTrue($this->entity->access($operation));
-    $this->assertTrue($this->entity->access('create'));
-  }
-
-  /**
-   * @covers ::language
-   */
-  public function testLanguage() {
-    $this->assertInstanceOf('\Drupal\Core\Language\Language', $this->entity->language());
-  }
-
-  /**
-   * @covers ::save
-   */
-  public function testSave() {
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $storage->expects($this->once())
-      ->method('save')
-      ->with($this->entity);
-    $this->entityManager->expects($this->once())
-      ->method('getStorageController')
-      ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
-    $this->entity->save();
-  }
-
-  /**
-   * @covers ::delete
-   */
-  public function testDelete() {
-    $this->entity->id = $this->randomName();
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    // Testing the argument of the delete() method consumes too much memory.
-    $storage->expects($this->once())
-      ->method('delete');
-    $this->entityManager->expects($this->once())
-      ->method('getStorageController')
-      ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
-    $this->entity->delete();
-  }
-
-  /**
-   * @covers ::getEntityTypeId
-   */
-  public function testGetEntityTypeId() {
-    $this->assertSame($this->entityTypeId, $this->entity->getEntityTypeId());
-  }
-
-  /**
-   * @covers ::preSave
-   */
-  public function testPreSave() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $this->entity->preSave($storage);
-  }
-
-  /**
-   * @covers ::postSave
-   */
-  public function testPostSave() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $this->entity->postSave($storage);
-  }
-
-  /**
-   * @covers ::preCreate
-   */
-  public function testPreCreate() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $values = array();
-    $this->entity->preCreate($storage, $values);
-  }
-
-  /**
-   * @covers ::postCreate
-   */
-  public function testPostCreate() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $this->entity->postCreate($storage);
-  }
-
-  /**
-   * @covers ::preDelete
-   */
-  public function testPreDelete() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $this->entity->preDelete($storage, array($this->entity));
-  }
-
-  /**
-   * @covers ::postDelete
-   */
-  public function testPostDelete() {
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-
-    $entity = $this->getMockBuilder('\Drupal\Core\Entity\Entity')
-      ->setMethods(array('onSaveOrDelete'))
-      ->disableOriginalConstructor()
-      ->getMock();
-    $entity->expects($this->once())
-      ->method('onSaveOrDelete');
-
-    $this->entity->postDelete($storage, array($entity));
-  }
-
-  /**
-   * @covers ::postLoad
-   */
-  public function testPostLoad() {
-    // This method is internal, so check for errors on calling it only.
-    $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface');
-    $entities = array($this->entity);
-    $this->entity->postLoad($storage, $entities);
-  }
-
-  /**
-   * @covers ::referencedEntities
-   */
-  public function testReferencedEntities() {
-    $this->assertSame(array(), $this->entity->referencedEntities());
-  }
-}
