You are here

protected function KeyValueEntityStorageTest::setUpKeyValueEntityStorage 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::setUpKeyValueEntityStorage()

Prepares the key value entity storage.

@covers ::__construct

Parameters

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

18 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 93
Contains \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest.

Class

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

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') {
  $this->entityType
    ->expects($this
    ->atLeastOnce())
    ->method('getKey')
    ->will($this
    ->returnValueMap(array(
    array(
      'id',
      'id',
    ),
    array(
      'uuid',
      $uuid_key,
    ),
    array(
      'langcode',
      'langcode',
    ),
  )));
  $this->entityType
    ->expects($this
    ->atLeastOnce())
    ->method('id')
    ->will($this
    ->returnValue('test_entity_type'));
  $this->entityType
    ->expects($this
    ->any())
    ->method('getListCacheTags')
    ->willReturn(array(
    'test_entity_type_list',
  ));
  $this->entityManager = $this
    ->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->with('test_entity_type')
    ->will($this
    ->returnValue($this->entityType));
  $this->cacheTagsInvalidator = $this
    ->getMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
  $this->keyValueStore = $this
    ->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreInterface');
  $this->moduleHandler = $this
    ->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->uuidService = $this
    ->getMock('Drupal\\Component\\Uuid\\UuidInterface');
  $this->languageManager = $this
    ->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
  $language = new Language(array(
    'langcode' => 'en',
  ));
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getDefaultLanguage')
    ->will($this
    ->returnValue($language));
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->will($this
    ->returnValue($language));
  $this->entityStorage = new KeyValueEntityStorage($this->entityType, $this->keyValueStore, $this->uuidService, $this->languageManager);
  $this->entityStorage
    ->setModuleHandler($this->moduleHandler);
  $container = new ContainerBuilder();
  $container
    ->set('entity.manager', $this->entityManager);
  $container
    ->set('language_manager', $this->languageManager);
  $container
    ->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
  \Drupal::setContainer($container);
}