Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  Use createMock() instead of a getter
  [ErrorHandler] Fix strpos error when trying to call a method without a name
  use proper keys to not override appended files
  Fix console logger according to PSR-3
  • Loading branch information
jderusse committed Jan 28, 2021
2 parents 196f457 + 64aa7b2 commit 4adc8d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ public function append(iterable $iterator)
} 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 {
Expand Down
11 changes: 11 additions & 0 deletions Tests/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,17 @@ public function testAppendDoesNotRequireIn()
$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);
Expand Down

0 comments on commit 4adc8d1

Please sign in to comment.