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 @@ -9,8 +9,8 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\Entity; -use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Config\ConfigDuplicateUUIDException; +use Drupal\Core\Entity\EntityStorageControllerInterface; /** * Defines a base configuration entity class. diff -u b/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php --- b/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -968,11 +968,10 @@ * {@inheritdoc} */ public function label() { - $label = NULL; + $label = ''; $entity_info = $this->entityInfo(); - // @todo Convert to is_callable() and call_user_func(). - if (($label_callback = $entity_info->getLabelCallback()) && function_exists($label_callback)) { - $label = $label_callback($this); + if (($label_callback = $entity_info->getLabelCallback()) && is_callable($label_callback)) { + $label = call_user_func($label_callback, $this); } elseif (($label_key = $entity_info->getKey('label')) && isset($this->{$label_key})) { $label = $this->{$label_key}->value; diff -u b/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php --- b/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -38,6 +38,13 @@ protected $uuidGenerator; /** + * The entity info used for testing.. + * + * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityInfo; + + /** * The entity type. * * @var string @@ -165,7 +172,6 @@ public function label() { $label = NULL; $entity_info = $this->entityInfo(); - // @todo Convert to is_callable() and call_user_func(). if (($label_callback = $entity_info->getLabelCallback()) && is_callable($label_callback)) { $label = call_user_func($label_callback, $this); } @@ -248,7 +254,6 @@ // Invoke the callback to get the URI. If there is no callback, use the // default URI format. - // @todo Convert to is_callable() and call_user_func(). if (isset($uri_callback) && is_callable($uri_callback)) { $uri = call_user_func($uri_callback, $this); } 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 @@ -10,7 +10,7 @@ use Drupal\Tests\UnitTestCase; /** - * Tests \Drupal\Core\Config\Entity\ConfigEntityBase. + * @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase * * @group Drupal */ @@ -24,6 +24,13 @@ 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 @@ -38,13 +45,6 @@ protected $entityType; /** - * The definition/type of the entity under test. - * - * @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $entityDefinition; - - /** * The route provider used for testing. * * @var \Drupal\Core\Routing\RouteProviderInterface|\PHPUnit_Framework_MockObject_MockObject @@ -75,9 +75,14 @@ public function setUp() { $values = array(); $this->entityType = $this->randomName(); - $this->entityDefinition = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + + $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->routeProvider = $this->getMock('\Drupal\Core\Routing\RouteProviderInterface'); @@ -102,7 +107,8 @@ } /** - * Tests setOriginalId() and getOriginalId(). + * @covers ::setOriginalId + * @covers ::getOriginalId */ public function testGetOriginalId() { $id = $this->randomName(); @@ -111,7 +117,7 @@ } /** - * Tests isNew(). + * @covers ::isNew */ public function testIsNew() { $this->assertFalse($this->entity->isNew()); @@ -122,7 +128,8 @@ } /** - * Tests set() and get(). + * @covers ::set + * @covers ::get */ public function testGet() { $name = $this->randomName(); @@ -133,7 +140,8 @@ } /** - * Tests setStatus() and status(). + * @covers ::setStatus + * @covers ::status */ public function testSetStatus() { $this->assertTrue($this->entity->status()); @@ -144,8 +152,7 @@ } /** - * Tests enable(). - * + * @covers ::enable * @depends testSetStatus */ public function testEnable() { @@ -155,8 +162,7 @@ } /** - * Tests disable(). - * + * @covers ::disable * @depends testSetStatus */ public function testDisable() { @@ -166,7 +172,8 @@ } /** - * Tests setSyncing() and isSyncing(). + * @covers ::setSyncing + * @covers ::isSyncing */ public function testIsSyncing() { $this->assertFalse($this->entity->isSyncing()); @@ -177,17 +184,13 @@ } /** - * Tests createDuplicate(). + * @covers ::createDuplicate */ public function testCreateDuplicate() { - $this->entityDefinition->expects($this->once()) + $this->entityInfo->expects($this->once()) ->method('getKey') ->with('id') ->will($this->returnValue('id')); - $this->entityManager->expects($this->once()) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue($this->entityDefinition)); $this->entity->setOriginalId('foo'); /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $duplicate */ @@ -200,7 +203,7 @@ } /** - * Tests sort(). + * @covers ::sort */ public function testSort() { $this->entityManager->expects($this->any()) @@ -227,7 +230,7 @@ } /** - * Tests getExportProperties(). + * @covers ::getExportProperties */ public function testGetExportProperties() { $properties = $this->entity->getExportProperties(); @@ -235,16 +238,7 @@ } /** - * Tests 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); - } - - /** - * Tests uri(). + * @covers ::uri */ public function testUri() { // The only difference between ConfigEntityBase::uri() and Entity::uri() is @@ -253,21 +247,21 @@ $expected_template_path = 'foo/' . $this->entity->id(); $route_name = 'foo.bar'; $route_path = 'foo/{id}'; - $this->entityManager->expects($this->once()) - ->method('getDefinition') - ->with($this->entityType) + + $this->entityInfo->expects($this->any()) + ->method('getLinkTemplates') ->will($this->returnValue(array( - 'links' => array( - 'edit-form' => $route_name, - ), + 'edit-form' => $route_name, ))); + $route = $this->getMockBuilder('\Symfony\Component\Routing\Route') ->disableOriginalConstructor() ->getMock(); $route->expects($this->once()) ->method('getPath') ->will($this->returnValue($route_path)); - $this->routeProvider->expects($this->once()) + + $this->routeProvider->expects($this->any()) ->method('getRouteByName') ->with($route_name) ->will($this->returnValue($route)); 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 @@ -7,10 +7,11 @@ namespace Drupal\Tests\Core\Entity; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Tests\UnitTestCase; /** - * Tests \Drupal\Core\Entity\ContentEntityBase. + * @coversDefaultClass \Drupal\Core\Entity\ContentEntityBase * * @group Drupal */ @@ -31,6 +32,13 @@ 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 @@ -77,8 +85,14 @@ $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( @@ -93,53 +107,46 @@ ->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('entityManager', 'languageList', 'languageLoad', 'typedDataManager', 'uuidGenerator')) + ->setMethods(array('languageList', 'languageLoad')) ->getMockForAbstractClass(); $this->entity->expects($this->any()) - ->method('entityManager') - ->will($this->returnValue($this->entityManager)); - $this->entity->expects($this->any()) ->method('languageList') ->will($this->returnValue(array())); $this->entity->expects($this->any()) ->method('languageLoad') ->will($this->returnValue(NULL)); - $this->entity->expects($this->any()) - ->method('typedDataManager') - ->will($this->returnValue($this->typedDataManager)); - $this->entity->expects($this->any()) - ->method('uuidGenerator') - ->will($this->returnValue($this->uuid)); } /** - * Tests isNewRevision() and setNewRevision(). + * @covers ::isNewRevision + * @covers ::setNewRevision */ public function testIsNewRevision() { - $this->entityManager->expects($this->at(3)) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'entity_keys' => array( - 'revision' => $this->randomName(), - ), - ))); - // The value defaults to FALSE. - $this->assertFalse($this->entity->isNewRevision()); - // Set the value explicitly and test it is returned. - $this->entity->setNewRevision(TRUE); - $this->assertTrue($this->entity->isNewRevision()); - // Reset the value and test it is returned. - $this->entity->setNewRevision(FALSE); + $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()); - // Because isNewRevision() can now find an entity key, it returns TRUE. $this->assertTrue($this->entity->isNewRevision()); + $this->entity->setNewRevision(TRUE); + $this->assertTRUE($this->entity->isNewRevision()); } /** - * Tests isDefaultRevision(). + * @covers ::isDefaultRevision */ public function testIsDefaultRevision() { // The default value is TRUE. @@ -151,14 +158,14 @@ } /** - * Tests getRevisionId(). + * @covers ::getRevisionId */ public function testGetRevisionId() { $this->assertNull($this->entity->getRevisionId()); } /** - * Tests isTranslatable(). + * @covers ::isTranslatable */ public function testIsTranslatable() { $this->entityManager->expects($this->at(0)) @@ -174,7 +181,7 @@ } /** - * Tests preSaveRevision(). + * @covers ::preSaveRevision */ public function testPreSaveRevision() { // This method is internal, so check for errors on calling it only. @@ -184,24 +191,22 @@ } /** - * Tests getDefinition(). + * @covers ::getDefinition */ public function testGetDefinition() { $definition = $this->entity->getDefinition(); - $this->assertInternalType('array', $definition); - $this->arrayHasKey('type', $definition); - $this->assertInternalType('string', $definition['type']); + $this->assertInstanceOf('\Drupal\Core\TypedData\DataDefinitionInterface', $definition); } /** - * Tests getString(). + * @covers ::getString */ public function testGetString() { $this->assertInternalType('string', $this->entity->getString()); } /** - * Tests validate(). + * @covers ::validate */ public function testValidate() { $validator = $this->getMock('\Symfony\Component\Validator\ValidatorInterface'); @@ -228,42 +233,42 @@ } /** - * Tests getConstraints(). + * @covers ::getConstraints */ public function testGetConstraints() { $this->assertInternalType('array', $this->entity->getConstraints()); } /** - * Tests getName(). + * @covers ::getName */ public function testGetName() { - $this->assertNull($this->entity->getConstraints()); + $this->assertNull($this->entity->getName()); } /** - * Tests getRoot(). + * @covers ::getRoot */ public function testGetRoot() { $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->getRoot())); } /** - * Tests getPropertyPath(). + * @covers ::getPropertyPath */ public function testGetPropertyPath() { $this->assertSame('', $this->entity->getPropertyPath()); } /** - * Tests getParent(). + * @covers ::getParent */ public function testGetParent() { $this->assertNull($this->entity->getParent()); } /** - * Tests setContext(). + * @covers ::setContext */ public function testSetContext() { $name = $this->randomName(); @@ -272,50 +277,14 @@ } /** - * Tests id(). - */ - public function testId() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests bundle(). + * @covers ::bundle */ public function testBundle() { $this->assertSame($this->bundle, $this->entity->bundle()); } /** - * Tests uuid(). - */ - public function testUuid() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests getIterator(). - */ - public function testGetIterator() { - $this->assertInstanceOf('\Traversable', $this->entity->getIterator()); - } - - /** - * Tests getPropertyDefinition(). - */ - public function testGetPropertyDefinition() { - $this->entityManager->expects($this->once()) - ->method('getFieldDefinitions') - ->with($this->entityType, $this->bundle) - ->will($this->returnValue($this->entity->baseFieldDefinitions($this->entityType))); - $definition = $this->entity->getPropertyDefinition('id'); - $this->assertInternalType('array', $definition); - $this->arrayHasKey('type', $definition); - } - - /** - * Tests getPropertyDefinitions(). + * @covers ::getPropertyDefinitions */ public function testGetPropertyDefinitions() { $definitions = $this->entity->getPropertyDefinitions(); @@ -324,7 +293,7 @@ } /** - * Tests access(). + * @covers ::access */ public function testAccess() { $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface'); @@ -345,112 +314,20 @@ /** - * Tests language(). - */ - public function testLanguage() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests getTranslation(). - */ - public function testGetTranslation() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests getUntranslated(). - */ - public function testGetUntranslated() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests hasTranslation(). - */ - public function testHasTranslation() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests initTranslation(). - */ - public function testInitTranslation() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests getTranslationLanguages(). - */ - public function testGetTranslationLanguages() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests translations(). - */ - public function testTranslations() { - // @todo Finish this test method. - $this->fail(); - } - - /** - * Tests createDuplicate(). - */ - public function testCreateDuplicate() { - $this->entityManager->expects($this->at(0)) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'entity_keys' => array( - 'id' => 'id', - 'revision' => 'revision', - 'uuid' => 'uuid', - ), - ))); - $duplicate = $this->entity->createDuplicate(); - $this->assertInstanceOf('\Drupal\Core\Entity\Entity', $duplicate); - $this->assertNotSame(spl_object_hash($this->entity), spl_object_hash($duplicate)); - } - - /** - * Tests label(). + * @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->entityManager->expects($this->at(0)) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'label_callback' => array($callback_container, __FUNCTION__), - ))); - - // 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->entityType) - ->will($this->returnValue(array( - 'entity_keys' => array( - 'label' => 'label', - ), - ))); - $this->entity->label = $property_label; + $this->entityInfo->expects($this->once()) + ->method('getLabelCallback') + ->will($this->returnValue(array($callback_container, __FUNCTION__))); $this->assertSame($callback_label, $this->entity->label()); - $this->assertSame($property_label, $this->entity->label()); } } 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 @@ -10,7 +10,7 @@ use Drupal\Tests\UnitTestCase; /** - * Tests \Drupal\Core\Entity\Entity. + * @coversDefaultClass \Drupal\Core\Entity\Entity * * @group Drupal */ @@ -24,6 +24,13 @@ 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 @@ -69,7 +76,13 @@ $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->routeProvider = $this->getMockBuilder('\Drupal\Core\Routing\RouteProvider') ->disableOriginalConstructor() @@ -96,7 +109,7 @@ } /** - * Tests id(). + * @covers ::id */ public function testId() { // @todo How to test this? @@ -104,7 +117,7 @@ } /** - * Tests uuid(). + * @covers ::uuid */ public function testUuid() { // @todo How to test this? @@ -112,7 +125,7 @@ } /** - * Tests isNew(). + * @covers ::isNew */ public function testIsNew() { // @todo How to test this? @@ -120,28 +133,28 @@ } /** - * Tests enforceIsNew(). + * @covers ::enforceIsNew */ public function testEnforceIsNew() { $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew())); } /** - * Tests entityType(). + * @covers ::entityType */ public function testEntityType() { $this->assertSame($this->entityType, $this->entity->entityType()); } /** - * Tests bundle(). + * @covers ::bundle */ public function testBundle() { $this->assertSame($this->entityType, $this->entity->bundle()); } /** - * Tests label(). + * @covers ::label */ public function testLabel() { // Make a mock with one method that we use as the entity's uri_callback. We @@ -153,12 +166,16 @@ $callback_container->expects($this->once()) ->method(__FUNCTION__) ->will($this->returnValue($callback_label)); - $this->entityManager->expects($this->at(0)) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'label_callback' => array($callback_container, __FUNCTION__), - ))); + $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. @@ -177,66 +194,7 @@ } /** - * Tests uri(). - */ - public function testUri() { - // Test link templates. - $this->entity->id = $this->randomName(); - $expected_template_path = 'foo/' . $this->entity->id(); - $route_name = 'foo.bar'; - $route_path = 'foo/{id}'; - $this->entityManager->expects($this->at(0)) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'links' => array( - 'canonical' => $route_name, - ), - ))); - $route = $this->getMockBuilder('\Symfony\Component\Routing\Route') - ->disableOriginalConstructor() - ->getMock(); - $route->expects($this->once()) - ->method('getPath') - ->will($this->returnValue($route_path)); - $this->routeProvider->expects($this->once()) - ->method('getRouteByName') - ->with($route_name) - ->will($this->returnValue($route)); - - // 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 uri is the callback's - // return value. - $expected_callback_path = $this->randomName(); - $uri = array( - 'path' => $expected_callback_path, - ); - $callback_container = $this->getMock(get_class()); - $callback_container->expects($this->once()) - ->method(__FUNCTION__) - ->will($this->returnValue($uri)); - $this->entityManager->expects($this->at(2)) - ->method('getBundleInfo') - ->with($this->entityType) - ->will($this->returnValue(array( - $this->entityType => array( - 'uri_callback' => array($callback_container, __FUNCTION__), - ), - ))); - - $actual_template_uri = $this->entity->uri(); - $this->assertSame($expected_template_path, $actual_template_uri['path']); - - $actual_callback_uri = $this->entity->uri(); - $this->assertSame($expected_callback_path, $actual_callback_uri['path']); - - $expected_fallback_path = 'entity/' . $this->entityType . '/' . $this->entity->id(); - $actual_fallback_uri = $this->entity->uri(); - $this->assertSame($expected_fallback_path, $actual_fallback_uri['path']); - } - - /** - * Tests access(). + * @covers ::access */ public function testAccess() { $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface'); @@ -256,14 +214,14 @@ } /** - * Tests language(). + * @covers ::language */ public function testLanguage() { $this->assertInstanceOf('\Drupal\Core\Language\Language', $this->entity->language()); } /** - * Tests save(). + * @covers ::save */ public function testSave() { $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); @@ -278,7 +236,7 @@ } /** - * Tests delete(). + * @covers ::delete */ public function testDelete() { $this->entity->id = $this->randomName(); @@ -294,28 +252,7 @@ } /** - * Tests createDuplicate(). - */ - public function testCreateDuplicate() { - $this->entityManager->expects($this->at(0)) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'entity_keys' => array( - 'id' => 'id', - 'uuid' => 'uuid', - ), - ))); - /** @var $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->uuid()); - } - - /** - * Tests entityInfo(). + * @covers ::entityInfo */ public function testEntityInfo() { $this->entityManager->expects($this->once()) @@ -325,7 +262,7 @@ } /** - * Tests preSave(). + * @covers ::preSave */ public function testPreSave() { // This method is internal, so check for errors on calling it only. @@ -334,7 +271,7 @@ } /** - * Tests postSave(). + * @covers ::postSave */ public function testPostSave() { // This method is internal, so check for errors on calling it only. @@ -343,7 +280,7 @@ } /** - * Tests preCreate(). + * @covers ::preCreate */ public function testPreCreate() { // This method is internal, so check for errors on calling it only. @@ -353,7 +290,7 @@ } /** - * Tests postCreate(). + * @covers ::postCreate */ public function testPostCreate() { // This method is internal, so check for errors on calling it only. @@ -362,7 +299,7 @@ } /** - * Tests preDelete(). + * @covers ::preDelete */ public function testPreDelete() { // This method is internal, so check for errors on calling it only. @@ -371,7 +308,7 @@ } /** - * Tests postDelete(). + * @covers ::postDelete */ public function testPostDelete() { // This method is internal, so check for errors on calling it only. @@ -380,7 +317,7 @@ } /** - * Tests postLoad(). + * @covers ::postLoad */ public function testPostLoad() { // This method is internal, so check for errors on calling it only. @@ -392,15 +329,7 @@ /** - * Tests referencedEntities(). + * @covers ::referencedEntities */ public function testReferencedEntities() { $this->assertSame(array(), $this->entity->referencedEntities()); } - - /** - * Tests changed(). - */ - public function testChanged() { - // This method is internal, so check for errors on calling it only. - $this->entity->changed(); - } } only in patch2: unchanged: --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -90,14 +90,4 @@ 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); - } - }