Issue #3325571 by Murz, andypost, smustgrave, catch, larowlan: MemoryStorage fails with "Argument #1 ($array) must be of type array" error on calling function readMultiple()

merge-requests/3189/merge
Lee Rowlands 2023-07-10 09:16:03 +10:00
parent 7d9c51d738
commit be366aec48
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
7 changed files with 5 additions and 12 deletions

View File

@ -31,6 +31,7 @@ class MemoryStorage implements StorageInterface {
public function __construct($collection = StorageInterface::DEFAULT_COLLECTION) {
$this->collection = $collection;
$this->config = new \ArrayObject();
$this->config[$collection] = [];
}
/**

View File

@ -37,8 +37,6 @@ class CachedStorageTest extends ConfigStorageTestBase {
$this->fileStorage = new FileStorage($dir);
$this->storage = new CachedStorage($this->fileStorage, \Drupal::service('cache.config'));
$this->cache = \Drupal::service('cache_factory')->get('config');
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', []);
}
/**

View File

@ -39,6 +39,9 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Checking whether a non-existing name exists returns FALSE.
$this->assertFalse($this->storage->exists($name));
// Checking whether readMultiple() works with empty storage.
$this->assertEmpty($this->storage->readMultiple([$name]));
// Reading a non-existing name returns FALSE.
$data = $this->storage->read($name);
$this->assertFalse($data);
@ -59,6 +62,7 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
$this->assertTrue($result);
// Listing all names returns all.
$this->storage->write('system.performance', []);
$names = $this->storage->listAll();
$this->assertContains('system.performance', $names);
$this->assertContains($name, $names);

View File

@ -20,9 +20,6 @@ class DatabaseStorageTest extends ConfigStorageTestBase {
$this->storage = new DatabaseStorage($this->container->get('database'), 'config');
$this->invalidStorage = new DatabaseStorage($this->container->get('database'), 'invalid');
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', []);
}
protected function read($name) {

View File

@ -28,8 +28,6 @@ class ManagedStorageTest extends ConfigStorageTestBase implements StorageManager
protected function setUp(): void {
parent::setUp();
$this->storage = new ManagedStorage($this);
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', []);
}
/**

View File

@ -17,8 +17,6 @@ class MemoryStorageTest extends ConfigStorageTestBase {
protected function setUp(): void {
parent::setUp();
$this->storage = new MemoryStorage();
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', []);
}
/**

View File

@ -18,9 +18,6 @@ class StorageReplaceDataWrapperTest extends ConfigStorageTestBase {
protected function setUp(): void {
parent::setUp();
$this->storage = new StorageReplaceDataWrapper($this->container->get('config.storage'));
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', []);
$this->storage->replaceData('system.performance', ['foo' => 'bar']);
}
/**