diff --git a/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php b/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php index 5ba7f5e..2101d93 100644 --- a/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php +++ b/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Tests\Entity; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\Core\Entity\EntityType; use Drupal\Tests\UnitTestCase; /** @@ -74,10 +75,16 @@ public function testLocks() { $comment->expects($this->any()) ->method('getThread') ->will($this->returnValue('')); - $comment->expects($this->at(0)) + + $entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $comment->expects($this->any()) + ->method('getEntityType') + ->will($this->returnValue($entity_type)); + $comment->expects($this->at(1)) ->method('get') ->with('status') ->will($this->returnValue((object) array('value' => NULL))); + $storage = $this->getMock('Drupal\comment\CommentStorageInterface'); $comment->preSave($storage); $comment->postSave($storage); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php index d26ccd1..db3e5d3 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php @@ -11,7 +11,7 @@ use Drupal\Tests\UnitTestCase; /** - * Tests the \Drupal\Core\Entity\EntityType class. + * @coversDefaultClass \Drupal\Core\Entity\EntityType * * @group Drupal * @group Entity @@ -38,6 +38,9 @@ public static function getInfo() { * @return \Drupal\Core\Entity\EntityTypeInterface */ protected function setUpEntityType($definition) { + $definition += array( + 'id' => 'example_entity_type', + ); return new EntityType($definition); } @@ -191,6 +194,26 @@ public function testGetViewBuilderClass() { } /** + * @covers ::__construct + */ + public function testIdExceedsMaxLength() { + $id = $this->randomName(33); + $message = 'Attempt to create an entity type with an ID longer than 32 characters: ' . $id; + $this->setExpectedException('Drupal\Core\Entity\EntityMalformedException', $message); + $this->setUpEntityType(array('id' => $id)); + } + + + /** + * @covers ::id + */ + public function testId() { + $id = $this->randomName(32); + $entity_type = $this->setUpEntityType(array('id' => $id)); + $this->assertEquals($id, $entity_type->id()); + } + + /** * Gets a mock controller class name. * * @return string