Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Utils/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ private function traverseDir(string $dir, array $searches, array $subdirs = []):
$relativePathname = FileSystem::unixSlashes($file->getRelativePathname());
foreach ($searches as $search) {
if (
$file->getType() === $search->mode
(
$file->getType() === $search->mode
|| ($file->getType() === 'link' && in_array($search->mode, ['file', 'dir'], true))
)
&& preg_match($search->pattern, $relativePathname)
&& $this->proveFilters($this->filters, $file, $cache)
) {
Expand Down
23 changes: 22 additions & 1 deletion tests/Utils/Finder.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function export($iterator, bool $sort = true)
}


test('expty search', function () {
test('empty search', function () {
$finder = (new Finder)->in('fixtures.finder');
Assert::same([], export($finder));

Expand Down Expand Up @@ -172,3 +172,24 @@ test('absolute path in mask', function () { // will not work if there are charac
FileSystem::unixSlashes(__DIR__),
], export($finder));
});

test('symlink to file', function() {
$finder = Finder::find('subdir/*.txt')->in('fixtures.finder3');
Assert::same([
'fixtures.finder3/subdir/file.txt',
], export($finder));
});

test('symlink to directory', function() {
$finder = Finder::findDirectories()->in('fixtures.finder3/another_subdir');
Assert::same([
'fixtures.finder3/another_subdir/subdir',
], export($finder));
});

test('symlink to file in symlinked directory', function() {
$finder = Finder::find('subdir/*.txt')->in('fixtures.finder3/another_subdir');
Assert::same([
'fixtures.finder3/another_subdir/subdir/file.txt',
], export($finder));
});
1 change: 1 addition & 0 deletions tests/Utils/fixtures.finder3/another_subdir/subdir
1 change: 1 addition & 0 deletions tests/Utils/fixtures.finder3/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File for testing purposes
1 change: 1 addition & 0 deletions tests/Utils/fixtures.finder3/subdir/file.txt