From 0e5ad52d5e45d85ca2adf9bb8a7bcc471858cd14 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 6 Dec 2023 15:27:19 +0900 Subject: [PATCH] test: add test for get_filenames() --- tests/system/Helpers/FilesystemHelperTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index e92505cc8a91..469c3bf74833 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -396,6 +396,31 @@ public function testGetFilenamesFailure(): void $this->assertSame([], get_filenames(SUPPORTPATH . 'Files/shaker/')); } + public function testGetFilenamesWithSymlinks(): void + { + $targetDir = APPPATH . 'Language'; + $linkDir = APPPATH . 'Controllers/Language'; + file_exists($linkDir) && unlink($linkDir); + symlink($targetDir, $linkDir); + + $targetFile = APPPATH . 'Common.php'; + $linkFile = APPPATH . 'Controllers/Common.php'; + file_exists($linkFile) && unlink($linkFile); + symlink($targetFile, $linkFile); + + $this->assertSame([ + 0 => 'BaseController.php', + 1 => 'Common.php', + 2 => 'Home.php', + 3 => 'Language', + 4 => 'Validation.php', + 5 => 'en', + ], get_filenames(APPPATH . 'Controllers')); + + unlink($linkDir); + unlink($linkFile); + } + public function testGetDirFileInfo(): void { $file = SUPPORTPATH . 'Files/baker/banana.php';