function KeyValueEntityStorageTest::testCreateWithoutUuidKey

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testCreateWithoutUuidKey()
  2. 10 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testCreateWithoutUuidKey()
  3. 11.x 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 174

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')
        ->willReturn(get_class($this->getMockEntity()));
    $this->setUpKeyValueEntityStorage(NULL);
    $this->moduleHandler
        ->expects($this->exactly(2))
        ->method('invokeAll')
        ->withConsecutive([
        'test_entity_type_create',
    ], [
        'entity_create',
    ]);
    $this->uuidService
        ->expects($this->never())
        ->method('generate');
    $entity = $this->entityStorage
        ->create([
        'id' => 'foo',
        'uuid' => 'baz',
    ]);
    $this->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
    $this->assertSame('foo', $entity->id());
    $this->assertSame('baz', $entity->uuid());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.