diff -u b/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php --- b/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -149,14 +149,14 @@ /** * Sorts active blocks by weight; sorts inactive blocks by name. */ - public static function sort($a, $b) { + public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { // Separate enabled from disabled. $status = $b->get('status') - $a->get('status'); if ($status) { /** * 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 -u b/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 --- b/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 @@ -94,14 +94,14 @@ /** * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort(). */ - public static function sort($a, $b) { + public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { \Drupal::state()->set('config_entity_sort', TRUE); return parent::sort($a, $b); } /** * 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 -u b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php --- b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php @@ -61,16 +61,16 @@ /** * {@inheritdoc} */ - public static function sort($a, $b) { + public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { + /** @var \Drupal\entity\EntityDisplayModeInterface $a */ + /** @var \Drupal\entity\EntityDisplayModeInterface $b */ // Sort by the type of entity the view mode is used for. $a_type = $a->getTargetType(); $b_type = $b->getTargetType(); /** * {@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 -u b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php --- b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php +++ b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php @@ -214,14 +214,14 @@ /** * {@inheritdoc} */ - public static function sort($a, $b) { + public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { /** @var $a \Drupal\search\SearchPageInterface */ /** @var $b \Drupal\search\SearchPageInterface */ $a_status = (int) $a->status(); /** * {@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 -u b/core/modules/system/lib/Drupal/system/Entity/Action.php b/core/modules/system/lib/Drupal/system/Entity/Action.php --- b/core/modules/system/lib/Drupal/system/Entity/Action.php +++ b/core/modules/system/lib/Drupal/system/Entity/Action.php @@ -132,16 +132,16 @@ /** * {@inheritdoc} */ - public static function sort($a, $b) { + public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { + /** @var \Drupal\system\ActionConfigEntityInterface $a */ + /** @var \Drupal\system\ActionConfigEntityInterface $b */ $a_type = $a->getType(); $b_type = $b->getType(); if ($a_type != $b_type) { /** * {@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 -u b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php --- b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -224,4 +224,10 @@ $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 -u b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php --- b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -194,7 +194,17 @@ * @covers ::getString */ public function testGetString() { - $this->assertInternalType('string', $this->entity->getString()); + $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()); } /** diff -u b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php --- b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -301,9 +301,16 @@ * @covers ::postDelete */ public function testPostDelete() { - // This method is internal, so check for errors on calling it only. $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entity->postDelete($storage, array($this->entity)); + + $entity = $this->getMockBuilder('\Drupal\Core\Entity\Entity') + ->setMethods(array('onSaveOrDelete')) + ->disableOriginalConstructor() + ->getMock(); + $entity->expects($this->once()) + ->method('onSaveOrDelete'); + + $this->entity->postDelete($storage, array($entity)); } /**