You are here

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

Test that the inner storage contains the grafted data.

File

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

Class

SplitCollectionStorageTest
Test the SplitCollectionStorage.

Namespace

Drupal\Tests\config_split\Kernel

Code

public function testGraft() {

  // 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',
  ]);
  $collection = $this->storage
    ->createCollection('test');
  $collection
    ->write('random', [
    'more',
  ]);

  // Copy all of what is in the inner one.
  $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([
    'collection',
    'split.graft',
    'split.graft.collection',
  ], $this->inner
    ->getAllCollectionNames());
  $collection
    ->write('graft', [
    'grafted',
  ]);
  self::assertEquals([
    'collection',
    'split.graft',
    'split.graft.collection',
    'split.graft.test',
  ], $this->inner
    ->getAllCollectionNames());
  self::assertEquals([
    'grafted',
  ], $this->inner
    ->createCollection('split.graft.test')
    ->read('graft'));
}