You are here

protected function SplitTestTrait::createSplitConfig in Configuration Split 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/SplitTestTrait.php \Drupal\Tests\config_split\Kernel\SplitTestTrait::createSplitConfig()

Create a split configuration.

Parameters

string $name: The name of the split.

array $data: The split config data.

Return value

\Drupal\Core\Config\Config The split config object.

5 calls to SplitTestTrait::createSplitConfig()
IndividualExportImportTest::setUp in tests/src/Kernel/IndividualExportImportTest.php
SplitMergeTest::testCompleteAndConditionalSplitExport in tests/src/Kernel/SplitMergeTest.php
Test complete and conditional split export.
SplitMergeTest::testConditionalSplitWithModuleConfig in tests/src/Kernel/SplitMergeTest.php
Test complete and conditional split export with modules.
SplitMergeTest::testIncludeDependency in tests/src/Kernel/SplitMergeTest.php
Test that dependencies are split too.
SplitMergeTest::testSimpleSplitExport in tests/src/Kernel/SplitMergeTest.php
Test a simple export split.

File

tests/src/Kernel/SplitTestTrait.php, line 27

Class

SplitTestTrait
Trait to facilitate creating split configurations.

Namespace

Drupal\Tests\config_split\Kernel

Code

protected function createSplitConfig(string $name, array $data) : Config {
  if (substr($name, 0, strlen('config_split.config_split.')) !== 'config_split.config_split.') {

    // Allow using the id as the config name to keep it short.
    $name = 'config_split.config_split.' . $name;
  }

  // Add default values.
  $data += [
    'folder' => '',
    'module' => [],
    'theme' => [],
    'blacklist' => [],
    'graylist' => [],
    'status' => TRUE,
    'graylist_dependents' => TRUE,
    'graylist_skip_equal' => TRUE,
    'weight' => 0,
  ];

  // Set the id from the name.
  $data['id'] = substr($name, strlen('config_split.config_split.'));

  // Create the config.
  $config = new Config($name, $this->container
    ->get('config.storage'), $this->container
    ->get('event_dispatcher'), $this->container
    ->get('config.typed'));
  $config
    ->initWithData($data)
    ->save();
  return $config;
}