function CheckpointStorageTest::setRandomFixtureConfig

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php \Drupal\Tests\Core\Config\Checkpoint\CheckpointStorageTest::setRandomFixtureConfig()

Generate random config in the memory storage.

Parameters

array $config: The config keys, keyed by the collection.

3 calls to CheckpointStorageTest::setRandomFixtureConfig()
CheckpointStorageTest::testCollections in core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php
@covers ::getAllCollectionNames[[api-linebreak]] @covers ::getCollectionName[[api-linebreak]] @covers ::createCollection[[api-linebreak]]
CheckpointStorageTest::testReadOperations in core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php
@covers ::exists[[api-linebreak]] @covers ::read[[api-linebreak]] @covers ::readMultiple[[api-linebreak]] @covers ::listAll[[api-linebreak]]
CheckpointStorageTest::testWriteOperations in core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php
@covers ::write[[api-linebreak]] @covers ::delete[[api-linebreak]] @covers ::rename[[api-linebreak]] @covers ::deleteAll[[api-linebreak]]

File

core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php, line 281

Class

CheckpointStorageTest
@coversDefaultClass \Drupal\Core\Config\Checkpoint\CheckpointStorage[[api-linebreak]] @group Config

Namespace

Drupal\Tests\Core\Config\Checkpoint

Code

protected function setRandomFixtureConfig(array $config) : void {
  // Erase previous fixture.
  foreach (array_merge([
    StorageInterface::DEFAULT_COLLECTION,
  ], $this->memory
    ->getAllCollectionNames()) as $collection) {
    $this->memory
      ->createCollection($collection)
      ->deleteAll();
  }
  foreach ($config as $collection => $keys) {
    $storage = $this->memory
      ->createCollection($collection);
    foreach ($keys as $key) {
      // Create some random config.
      $storage->write($key, (array) $this->getRandomGenerator()
        ->object());
    }
  }
}

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