You are here

public function SplitCollectionStorageTest::testSiblings in Configuration Split 2.0.x

Test two storages grafted onto the same one.

File

tests/src/Kernel/SplitCollectionStorageTest.php, line 64

Class

SplitCollectionStorageTest
Test the SplitCollectionStorage.

Namespace

Drupal\Tests\config_split\Kernel

Code

public function testSiblings() {
  $sibling = new SplitCollectionStorage($this->inner, 'sibling');

  // Empty out all of the underlying storage.
  $this
    ->copyConfig(new NullStorage(), $this->inner);

  // Add some data.
  $this->inner
    ->write('inner', [
    'test data',
  ]);
  $this->inner
    ->createCollection('collection')
    ->write('collection', [
    'collection data',
  ]);
  $this
    ->copyConfig($this->inner, $this->storage);
  $this
    ->copyConfig($this->inner, $sibling);
  $this
    ->copyConfig($this->inner, $this->storage);
  self::assertEquals([
    'inner',
  ], $this->storage
    ->listAll());
  self::assertEquals([
    'collection',
  ], $this->storage
    ->getAllCollectionNames());
  self::assertEquals([
    'test data',
  ], $this->storage
    ->read('inner'));
  self::assertEquals([
    'collection data',
  ], $this->storage
    ->createCollection('collection')
    ->read('collection'));
  self::assertEquals([
    'inner',
  ], $sibling
    ->listAll());
  self::assertEquals([
    'collection',
  ], $sibling
    ->getAllCollectionNames());
  self::assertEquals([
    'test data',
  ], $sibling
    ->read('inner'));
  self::assertEquals([
    'collection data',
  ], $sibling
    ->createCollection('collection')
    ->read('collection'));
  self::assertEquals([
    'collection',
    'split.graft',
    'split.graft.collection',
    'split.sibling',
    'split.sibling.collection',
  ], $this->inner
    ->getAllCollectionNames());
}