Skip to content
Snippets Groups Projects
Verified Commit de15d044 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3001979 by alexpott:...

Issue #3001979 by alexpott: \Drupal\Core\Config\FileStorage::getAllCollectionNames() should work when the directory does not exist
parent 12c31093
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment