Skip to content

Commit c1bac7e

Browse files
authored
Merge pull request #6291 from kenjis/fix-FileCollection-constructor
fix: unable to add more than one file to FileCollection constructor
2 parents f781dc2 + c79225e commit c1bac7e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

system/Files/FileCollection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ public function add($paths, bool $recursive = true)
178178
// Test for a directory
179179
self::resolveDirectory($path);
180180
} catch (FileException $e) {
181-
return $this->addFile($path);
181+
$this->addFile($path);
182+
183+
continue;
182184
}
183185

184186
$this->addDirectory($path, $recursive);

tests/system/Files/FileCollectionTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,24 @@ public function testAddStringDirectoryRecursive()
178178
$this->assertSame($expected, $files->get());
179179
}
180180

181-
public function testAddArray()
181+
public function testAddArrayFiles()
182+
{
183+
$files = new FileCollection();
184+
185+
$expected = [
186+
$this->directory . 'apple.php',
187+
SUPPORTPATH . 'Files/baker/banana.php',
188+
];
189+
190+
$files->add([
191+
$this->directory . 'apple.php',
192+
SUPPORTPATH . 'Files/baker/banana.php',
193+
]);
194+
195+
$this->assertSame($expected, $files->get());
196+
}
197+
198+
public function testAddArrayDirectoryAndFile()
182199
{
183200
$files = new FileCollection();
184201

@@ -190,7 +207,7 @@ public function testAddArray()
190207
];
191208

192209
$files->add([
193-
SUPPORTPATH . 'Files/able',
210+
SUPPORTPATH . 'Files/able', // directory
194211
SUPPORTPATH . 'Files/baker/banana.php',
195212
]);
196213

0 commit comments

Comments
 (0)