public function ConfigSplitKernelTest::testSerialisation in Configuration Split 8
Test that splits can be serialized.
File
- tests/
src/ Kernel/ ConfigSplitKernelTest.php, line 44
Class
- ConfigSplitKernelTest
- Integration test.
Namespace
Drupal\Tests\config_split\KernelCode
public function testSerialisation() {
$vfs = vfsStream::setup('split');
$primary = new FileStorage($vfs
->url() . '/sync');
$folder_config = new Config('config_split.config_split.folder_split', $this->container
->get('config.storage'), $this->container
->get('event_dispatcher'), $this->container
->get('config.typed'));
$folder_config
->initWithData([
'id' => 'folder_split',
'folder' => $vfs
->url() . '/split',
'module' => [],
'theme' => [],
'blacklist' => [
'config_test.system',
],
'graylist' => [],
])
->save();
$folder_split = SplitFilter::create($this->container, [
'config_name' => 'config_split.config_split.folder_split',
], 'config_split:folder_split', []);
$db_config = new Config('config_split.config_split.db_split', $this->container
->get('config.storage'), $this->container
->get('event_dispatcher'), $this->container
->get('config.typed'));
$db_config
->initWithData([
'id' => 'db_split',
'folder' => '',
'module' => [],
'theme' => [],
'blacklist' => [
'config_test.types',
],
'graylist' => [],
])
->save();
$db_split = SplitFilter::create($this->container, [
'config_name' => 'config_split.config_split.db_split',
], 'config_split:db_split', []);
// Create the filtered storage with a folder split and a database split.
$filtered = new FilteredStorage($primary, [
$folder_split,
$db_split,
]);
// Export the configuration.
$this
->copyConfig($this->container
->get('config.storage'), $filtered);
// Read from the split folder, the database and the sync directory.
$test_system = $filtered
->read('config_test.system');
$test_types = $filtered
->read('config_test.types');
$test_validation = $filtered
->read('config_test.validation');
$this
->assertEquals($this->container
->get('config.storage')
->read('config_test.system'), $test_system);
$this
->assertEquals($this->container
->get('config.storage')
->read('config_test.types'), $test_types);
$this
->assertEquals($this->container
->get('config.storage')
->read('config_test.validation'), $test_validation);
// Serialize and unserialize to make sure everything works.
$serialized = serialize($filtered);
$filtered = unserialize($serialized);
// Assert reading the same values returns the same things afterwards.
$this
->assertEquals($test_system, $filtered
->read('config_test.system'));
$this
->assertEquals($test_types, $filtered
->read('config_test.types'));
$this
->assertEquals($test_validation, $filtered
->read('config_test.validation'));
}