use proper keys to not override appended files
This commit is contained in:
parent
8533ea223e
commit
036c8d71fd
@ -669,7 +669,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
|
||||
$it = new \ArrayIterator();
|
||||
foreach ($iterator as $file) {
|
||||
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
|
||||
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
|
||||
$it[$file->getPathname()] = $file;
|
||||
}
|
||||
$this->iterators[] = $it;
|
||||
} else {
|
||||
|
@ -1119,6 +1119,17 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertIterator(iterator_to_array($finder->getIterator()), $finder1->getIterator());
|
||||
}
|
||||
|
||||
public function testMultipleAppendCallsWithSorting()
|
||||
{
|
||||
$finder = $this->buildFinder()
|
||||
->sortByName()
|
||||
->append([self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1000_1.php'])
|
||||
->append([self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1002_0.php'])
|
||||
;
|
||||
|
||||
$this->assertOrderedIterator($this->toAbsolute(['qux_1000_1.php', 'qux_1002_0.php']), $finder->getIterator());
|
||||
}
|
||||
|
||||
public function testCountDirectories()
|
||||
{
|
||||
$directory = Finder::create()->directories()->in(self::$tmpDir);
|
||||
|
Reference in New Issue
Block a user