You are here

protected function IgnoreKernelTest::setUpStorages in Config Ignore 8.3

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/IgnoreKernelTest.php \Drupal\Tests\config_ignore\Kernel\IgnoreKernelTest::setUpStorages()

Set up the active, sync and expected storages.

Parameters

array $active: Modifications to the active config.

array $sync: Modifications to the sync storage.

array $expected: Modifications to the expected storage.

Return value

\Drupal\Core\Config\StorageInterface The expected storage.

2 calls to IgnoreKernelTest::setUpStorages()
IgnoreKernelTest::testExport in tests/src/Kernel/IgnoreKernelTest.php
Test the export transformations.
IgnoreKernelTest::testImport in tests/src/Kernel/IgnoreKernelTest.php
Test the import transformations.

File

tests/src/Kernel/IgnoreKernelTest.php, line 262

Class

IgnoreKernelTest
Test the transformations.

Namespace

Drupal\Tests\config_ignore\Kernel

Code

protected function setUpStorages(array $active, array $sync, array $expected) : StorageInterface {

  // Copy the active config to the sync storage and the expected storage.
  $syncStorage = $this
    ->getSyncFileStorage();
  $expectedStorage = new MemoryStorage();
  $this
    ->copyConfig($this
    ->getActiveStorage(), $syncStorage);
  $this
    ->copyConfig($this
    ->getActiveStorage(), $expectedStorage);

  // Then modify the active storage by saving the config which was given.
  foreach ($active as $lang => $configs) {
    foreach ($configs as $name => $data) {
      if ($lang === '') {
        $config = $this
          ->config($name);
      }
      else {

        // Load the config override.
        $config = \Drupal::languageManager()
          ->getLanguageConfigOverride($lang, $name);
      }
      if ($data !== FALSE) {
        $config
          ->merge($data)
          ->save();
      }
      else {

        // If the data is not an array we want to delete it.
        $config
          ->delete();
      }
    }
  }

  // Apply modifications to the storages.
  static::modifyStorage($syncStorage, $sync);
  static::modifyStorage($expectedStorage, $expected);
  return $expectedStorage;
}