From f321e3fc59290f1eb99f94e87cc139065e7ed78f Mon Sep 17 00:00:00 2001 From: Jirka Hrazdil Date: Tue, 19 Sep 2023 11:55:16 +0200 Subject: [PATCH] fix symlink handling in Finder (#295) Co-authored-by: Jiri Hrazdil --- tests/Utils/Finder.basic.phpt | 23 ++++++++++++++++++- .../fixtures.finder3/another_subdir/subdir | 1 + tests/Utils/fixtures.finder3/file.txt | 1 + tests/Utils/fixtures.finder3/subdir/file.txt | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/Utils/fixtures.finder3/another_subdir/subdir create mode 100644 tests/Utils/fixtures.finder3/file.txt create mode 120000 tests/Utils/fixtures.finder3/subdir/file.txt diff --git a/tests/Utils/Finder.basic.phpt b/tests/Utils/Finder.basic.phpt index 053f24e6b..5d9a2457e 100644 --- a/tests/Utils/Finder.basic.phpt +++ b/tests/Utils/Finder.basic.phpt @@ -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)); @@ -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)); +}); diff --git a/tests/Utils/fixtures.finder3/another_subdir/subdir b/tests/Utils/fixtures.finder3/another_subdir/subdir new file mode 120000 index 000000000..61f519d04 --- /dev/null +++ b/tests/Utils/fixtures.finder3/another_subdir/subdir @@ -0,0 +1 @@ +../subdir \ No newline at end of file diff --git a/tests/Utils/fixtures.finder3/file.txt b/tests/Utils/fixtures.finder3/file.txt new file mode 100644 index 000000000..379e57270 --- /dev/null +++ b/tests/Utils/fixtures.finder3/file.txt @@ -0,0 +1 @@ +File for testing purposes diff --git a/tests/Utils/fixtures.finder3/subdir/file.txt b/tests/Utils/fixtures.finder3/subdir/file.txt new file mode 120000 index 000000000..1247f6970 --- /dev/null +++ b/tests/Utils/fixtures.finder3/subdir/file.txt @@ -0,0 +1 @@ +../file.txt \ No newline at end of file