function ReadOnlyStorageTest::testCollections

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

@covers ::getAllCollectionNames @covers ::getCollectionName @covers ::createCollection

File

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

Class

ReadOnlyStorageTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21ReadOnlyStorage.php/class/ReadOnlyStorage/9" 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

public function testCollections() {
    $fixture = [
        StorageInterface::DEFAULT_COLLECTION => [
            $this->randomMachineName(),
        ],
        'A' => [
            $this->randomMachineName(),
        ],
        'B' => [
            $this->randomMachineName(),
        ],
        'C' => [
            $this->randomMachineName(),
        ],
    ];
    $this->setRandomFixtureConfig($fixture);
    $this->assertEquals([
        'A',
        'B',
        'C',
    ], $this->storage
        ->getAllCollectionNames());
    foreach (array_keys($fixture) as $collection) {
        $storage = $this->storage
            ->createCollection($collection);
        // Assert that the collection storage is still a read-only storage.
        $this->assertInstanceOf(ReadOnlyStorage::class, $storage);
        $this->assertEquals($collection, $storage->getCollectionName());
    }
}

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