function StorageTestBase::createStorage

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php \Drupal\KernelTests\Core\KeyValueStore\StorageTestBase::createStorage()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php \Drupal\KernelTests\Core\KeyValueStore\StorageTestBase::createStorage()
  3. 11.x core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php \Drupal\KernelTests\Core\KeyValueStore\StorageTestBase::createStorage()

Creates storage objects for each collection defined for this class.

Storing the storage objects in a class member variable causes a fatal exception in DatabaseStorageExpirableTest, because in that situation garbage collection is not triggered until the test class itself is destructed, after tearDown() has deleted the database tables. Instead, create the storage objects locally in each test using this method.

See also

\Drupal\system\Tests\KeyValueStore\DatabaseStorageExpirable

\Drupal\Core\KeyValueStore\DatabaseStorageExpirable::garbageCollection()

7 calls to StorageTestBase::createStorage()
DatabaseStorageExpirableTest::testCRUDWithExpiration in core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
Tests CRUD functionality with expiration.
DatabaseStorageExpirableTest::testExpiration in core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
Tests data expiration.
StorageTestBase::testCRUD in core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
Tests CRUD operations.
StorageTestBase::testNonExistingKeys in core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
Tests expected behavior for non-existing keys.
StorageTestBase::testRename in core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
Tests the rename operation.

... See full list

File

core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php, line 222

Class

StorageTestBase
Base class for testing key-value storages.

Namespace

Drupal\KernelTests\Core\KeyValueStore

Code

protected function createStorage() {
    $stores = [];
    foreach ($this->collections as $i => $collection) {
        $stores[$i] = $this->container
            ->get($this->factory)
            ->get($collection);
    }
    return $stores;
}

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