function ReadOnlyStorageTest::setRandomFixtureConfig

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::setRandomFixtureConfig()
  2. 10 core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::setRandomFixtureConfig()
  3. 11.x core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::setRandomFixtureConfig()

Generate random config in the memory storage.

Parameters

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

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

File

core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php, line 181

Class

ReadOnlyStorageTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21ReadOnlyStorage.php/class/ReadOnlyStorage/8.9.x" title="A ReadOnlyStorage decorates a storage and does not allow writing to it." class="local">\Drupal\Core\Config\ReadOnlyStorage</a> @group Config

Namespace

Drupal\Tests\Core\Config

Code

protected function setRandomFixtureConfig($config) {
    // 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.