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

5 calls to StorageTestBase::createStorage()
DatabaseStorageExpirableTest::testCRUDWithExpiration in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/DatabaseStorageExpirableTest.php
Tests CRUD functionality with expiration.
DatabaseStorageExpirableTest::testExpiration in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/DatabaseStorageExpirableTest.php
Tests data expiration.
StorageTestBase::testCRUD in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
Tests CRUD operations.
StorageTestBase::testNonExistingKeys in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
Tests expected behavior for non-existing keys.
StorageTestBase::testSetIfNotExists in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
Tests the setIfNotExists() method.

File

drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php, line 208
Contains Drupal\system\Tests\KeyValueStore\StorageTestBase.

Class

StorageTestBase
Base class for testing key-value storages.

Namespace

Drupal\system\Tests\KeyValueStore

Code

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