You are here

public function KeyValueEntityStorageTest::testCreateWithoutUuidKey in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testCreateWithoutUuidKey()

@covers ::create @covers ::doCreate

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 167
Contains \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest.

Class

KeyValueEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function testCreateWithoutUuidKey() {

  // Set up the entity storage to expect no UUID key.
  $this->entityType
    ->expects($this
    ->once())
    ->method('getClass')
    ->will($this
    ->returnValue(get_class($this
    ->getMockEntity())));
  $this
    ->setUpKeyValueEntityStorage(NULL);
  $this->moduleHandler
    ->expects($this
    ->at(0))
    ->method('invokeAll')
    ->with('test_entity_type_create');
  $this->moduleHandler
    ->expects($this
    ->at(1))
    ->method('invokeAll')
    ->with('entity_create');
  $this->uuidService
    ->expects($this
    ->never())
    ->method('generate');
  $entity = $this->entityStorage
    ->create(array(
    'id' => 'foo',
    'uuid' => 'baz',
  ));
  $this
    ->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
  $this
    ->assertSame('foo', $entity
    ->id());
  $this
    ->assertSame('baz', $entity
    ->uuid());
}