3 namespace Drupal\KernelTests\Core\Config\Storage;
5 use Drupal\config\StorageReplaceDataWrapper;
6 use Drupal\Core\Config\StorageInterface;
9 * Tests StorageReplaceDataWrapper operations.
13 class StorageReplaceDataWrapperTest extends ConfigStorageTestBase {
18 protected function setUp() {
20 $this->storage = new StorageReplaceDataWrapper($this->container->get('config.storage'));
21 // ::listAll() verifications require other configuration data to exist.
22 $this->storage->write('system.performance', []);
23 $this->storage->replaceData('system.performance', ['foo' => 'bar']);
29 protected function read($name) {
30 return $this->storage->read($name);
36 protected function insert($name, $data) {
37 $this->storage->write($name, $data);
43 protected function update($name, $data) {
44 $this->storage->write($name, $data);
50 protected function delete($name) {
51 $this->storage->delete($name);
57 public function testInvalidStorage() {
58 // No-op as this test does not make sense.
62 * Tests if new collections created correctly.
64 * @param string $collection
65 * The collection name.
67 * @dataProvider providerCollections
69 public function testCreateCollection($collection) {
70 $initial_collection_name = $this->storage->getCollectionName();
72 // Create new storage with given collection and check it is set correctly.
73 $new_storage = $this->storage->createCollection($collection);
74 $this->assertSame($collection, $new_storage->getCollectionName());
76 // Check collection not changed in the current storage instance.
77 $this->assertSame($initial_collection_name, $this->storage->getCollectionName());
81 * Data provider for testing different collections.
84 * Returns an array of collection names.
86 public function providerCollections() {
88 [StorageInterface::DEFAULT_COLLECTION],