function KeyValueEntityStorageTest::setUpKeyValueEntityStorage

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::setUpKeyValueEntityStorage()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::setUpKeyValueEntityStorage()
  3. 10 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::setUpKeyValueEntityStorage()

Prepares the key value entity storage.

@covers ::__construct

Parameters

string $uuid_key: (optional) The entity key used for the UUID. Defaults to 'uuid'.

16 calls to KeyValueEntityStorageTest::setUpKeyValueEntityStorage()
KeyValueEntityStorageTest::testCreate in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::create @covers ::doCreate
KeyValueEntityStorageTest::testCreateWithoutUuidKey in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::create @covers ::doCreate
KeyValueEntityStorageTest::testCreateWithPredefinedUuid in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::create @covers ::doCreate
KeyValueEntityStorageTest::testDelete in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::delete @covers ::doDelete
KeyValueEntityStorageTest::testDeleteNothing in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::delete @covers ::doDelete

... See full list

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 105

Class

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

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') : void {
    $this->entityType
        ->expects($this->atLeastOnce())
        ->method('getKey')
        ->willReturnMap([
        [
            'id',
            'id',
        ],
        [
            'uuid',
            $uuid_key,
        ],
        [
            'langcode',
            'langcode',
        ],
    ]);
    $this->entityType
        ->expects($this->atLeastOnce())
        ->method('id')
        ->willReturn('test_entity_type');
    $this->entityType
        ->expects($this->any())
        ->method('getListCacheTags')
        ->willReturn([
        'test_entity_type_list',
    ]);
    $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
    $this->entityTypeManager
        ->expects($this->any())
        ->method('getDefinition')
        ->with('test_entity_type')
        ->willReturn($this->entityType);
    $this->entityFieldManager = $this->createMock(EntityFieldManagerInterface::class);
    $this->cacheTagsInvalidator = $this->createMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
    $this->keyValueStore = $this->createMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreInterface');
    $this->moduleHandler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $this->uuidService = $this->createMock('Drupal\\Component\\Uuid\\UuidInterface');
    $this->languageManager = $this->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
    $language = new Language([
        'langcode' => 'en',
    ]);
    $this->languageManager
        ->expects($this->any())
        ->method('getDefaultLanguage')
        ->willReturn($language);
    $this->languageManager
        ->expects($this->any())
        ->method('getCurrentLanguage')
        ->willReturn($language);
    $this->entityStorage = new KeyValueEntityStorage($this->entityType, $this->keyValueStore, $this->uuidService, $this->languageManager, new MemoryCache(new Time()));
    $this->entityStorage
        ->setModuleHandler($this->moduleHandler);
    $container = new ContainerBuilder();
    $container->set('entity_field.manager', $this->entityFieldManager);
    $container->set('entity_type.manager', $this->entityTypeManager);
    $container->set('language_manager', $this->languageManager);
    $container->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
    \Drupal::setContainer($container);
}

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