Skip to content

Commit

Permalink
fix symlink handling in Finder (#295)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiri Hrazdil <jiri@hrazdil.info>
  • Loading branch information
2 people authored and dg committed Sep 19, 2023
1 parent 6ffe33b commit f321e3f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
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

0 comments on commit f321e3f

Please sign in to comment.