public function SplitMergeTest::testConditionalSplitWithModuleConfig in Configuration Split 2.0.x
Same name and namespace in other branches
- 8 tests/src/Kernel/SplitMergeTest.php \Drupal\Tests\config_split\Kernel\SplitMergeTest::testConditionalSplitWithModuleConfig()
Test complete and conditional split export with modules.
@dataProvider storageAlternativesProvider
File
- tests/
src/ Kernel/ SplitMergeTest.php, line 231
Class
- SplitMergeTest
- Test the splitting and merging.
Namespace
Drupal\Tests\config_split\KernelCode
public function testConditionalSplitWithModuleConfig($storage) {
$config = $this
->createSplitConfig('test_split', [
'storage' => $storage,
'module' => [
'config_test' => 0,
],
'partial_list' => [
'config_test.system',
],
]);
$active = $this
->getActiveStorage();
// Export the configuration to sync without filtering.
$this
->copyConfig($active, $this
->getSyncFileStorage());
// Change the config which is partially split to see how it is exported.
$this
->config('config_test.system')
->set('foo', 'baz')
->save();
$expectedExport = new MemoryStorage();
$expectedSplit = new MemoryStorage();
// Set up the expected data.
foreach (array_merge([
StorageInterface::DEFAULT_COLLECTION,
], $active
->getAllCollectionNames()) as $collection) {
$active = $active
->createCollection($collection);
$expectedExport = $expectedExport
->createCollection($collection);
$expectedSplit = $expectedSplit
->createCollection($collection);
foreach ($active
->listAll() as $name) {
$data = $active
->read($name);
if ($name === 'core.extension') {
unset($data['module']['config_test']);
}
// The partial config does not take effect because it still depends
// explicitly on the module which is split off.
if (strpos($name, 'config_test') !== FALSE || in_array($name, [
'system.menu.exclude_test',
'system.menu.indirect_exclude_test',
])) {
// Expect config that depends on config_test directly and indirectly
// to be split off.
$expectedSplit
->write($name, $data);
}
else {
$expectedExport
->write($name, $data);
}
}
}
if ($storage === 'collection') {
$temp = new SplitCollectionStorage($expectedExport, $config
->get('id'));
self::replaceStorageContents($expectedSplit, $temp);
}
$export = $this
->getExportStorage();
static::assertStorageEquals($expectedExport, $export);
static::assertStorageEquals($expectedSplit, $this
->getSplitPreviewStorage($config, $export));
// Write the export to the file system and assert the import to work.
$this
->copyConfig($expectedExport, $this
->getSyncFileStorage());
$this
->copyConfig($expectedSplit, $this
->getSplitSourceStorage($config));
static::assertStorageEquals($active, $this
->getImportStorage());
}