// Set up the active storage collections to test import.
$test1_storage->
delete('config_test.create'
);
$test1_storage->
write('config_test.update',
['foo' => 'baz'
]);
$test1_storage->
write('config_test.delete',
['foo' => 'bar'
]);
$test2_storage->
delete('config_test.another_create'
);
$test2_storage->
write('config_test.another_update',
['foo' => 'baz'
]);
$test2_storage->
write('config_test.another_delete',
['foo' => 'bar'
]);
// Create a snapshot.
$snapshot_storage = \Drupal::
service('config.storage.snapshot'
);
\Drupal::
service('config.manager'
)->
createSnapshot($active_storage,
$snapshot_storage);
// Ensure that the snapshot has the expected collection data before import.
$test1_snapshot =
$snapshot_storage->
createCollection('collection.test1'
);
$data =
$test1_snapshot->
read('config_test.delete'
);
$this->
assertEquals(['foo' => 'bar'
],
$data, 'The config_test.delete in collection.test1 exists in the snapshot storage.'
);
$data =
$test1_snapshot->
read('config_test.update'
);
$this->
assertEquals(['foo' => 'baz'
],
$data, 'The config_test.update in collection.test1 exists in the snapshot storage.'
);
$this->
assertFalse($test1_snapshot->
read('config_test.create'
), 'The config_test.create in collection.test1 does not exist in the snapshot storage.'
);
$test2_snapshot =
$snapshot_storage->
createCollection('collection.test2'
);
$data =
$test2_snapshot->
read('config_test.another_delete'
);
$this->
assertEquals(['foo' => 'bar'
],
$data, 'The config_test.another_delete in collection.test2 exists in the snapshot storage.'
);