public function SplitMergeTest::testSimpleSplitExport 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::testSimpleSplitExport()
Test a simple export split.
@dataProvider storageAlternativesProvider
File
- tests/
src/ Kernel/ SplitMergeTest.php, line 80
Class
- SplitMergeTest
- Test the splitting and merging.
Namespace
Drupal\Tests\config_split\KernelCode
public function testSimpleSplitExport($storage) {
// Simple split with default configuration.
$config = $this
->createSplitConfig('test_split', [
'storage' => $storage,
'module' => [
'config_test' => 0,
],
]);
$active = $this
->getActiveStorage();
$expectedExport = new MemoryStorage();
$expectedSplit = new MemoryStorage();
// Set up expectations.
foreach (array_merge($active
->getAllCollectionNames(), [
StorageInterface::DEFAULT_COLLECTION,
]) 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') {
// We split off the module.
unset($data['module']['config_test']);
}
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());
}