Unverified Commit e09b77c3 authored by larowlan's avatar larowlan

Issue #3001979 by alexpott:...

Issue #3001979 by alexpott: \Drupal\Core\Config\FileStorage::getAllCollectionNames() should work when the directory does not exist

(cherry picked from commit de15d044)
parent 83e35e57
......@@ -279,6 +279,9 @@ public function getCollectionName() {
* {@inheritdoc}
*/
public function getAllCollectionNames() {
if (!is_dir($this->directory)) {
return [];
}
$collections = $this->getAllCollectionNamesHelper($this->directory);
sort($collections);
return $collections;
......@@ -305,7 +308,8 @@ public function getAllCollectionNames() {
* @param string $directory
* The directory to check for sub directories. This allows this
* function to be used recursively to discover all the collections in the
* storage.
* storage. It is the responsibility of the caller to ensure the directory
* exists.
*
* @return array
* A list of collection names contained within the provided directory.
......
......@@ -151,6 +151,11 @@ public function testInvalidStorage() {
// Listing on a non-existing storage bin returns an empty array.
$result = $this->invalidStorage->listAll();
$this->assertIdentical($result, []);
// Getting all collections on a non-existing storage bin return an empty
// array.
$this->assertSame([], $this->invalidStorage->getAllCollectionNames());
// Writing to a non-existing storage bin creates the bin.
$this->invalidStorage->write($name, ['foo' => 'bar']);
$result = $this->invalidStorage->read($name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment