protected function SplitTestTrait::createSplitConfig in Configuration Split 2.0.x
Same name and namespace in other branches
- 8 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.
6 calls to SplitTestTrait::createSplitConfig()
- InactiveSplitTest::testActiveInactive in tests/
src/ Kernel/ InactiveSplitTest.php - Test.
- 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.
File
- tests/
src/ Kernel/ SplitTestTrait.php, line 29
Class
- SplitTestTrait
- Trait to facilitate creating split configurations.
Namespace
Drupal\Tests\config_split\KernelCode
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 += [
'storage' => isset($data['folder']) && $data['folder'] != '' ? 'folder' : 'database',
'status' => TRUE,
'weight' => 0,
'folder' => isset($data['storage']) && $data['storage'] == 'folder' ? Settings::get('file_public_path') . '/config/split' : '',
'module' => [],
'theme' => [],
'complete_list' => [],
'partial_list' => [],
];
// 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;
}