diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index 891e5e1b0c3..0877de59b3b 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -218,6 +218,7 @@ public function findFiles(string $directory, string|false $matchExtension = fals $files->push(str_replace($directory.DIRECTORY_SEPARATOR, '', $file->getRealPath())); } - return $files; + // Sort files for consistent output + return $files->sort()->values(); } } diff --git a/packages/framework/tests/Unit/FilesystemFindFilesTest.php b/packages/framework/tests/Unit/FilesystemFindFilesTest.php index c535b61d037..9d97eeec877 100644 --- a/packages/framework/tests/Unit/FilesystemFindFilesTest.php +++ b/packages/framework/tests/Unit/FilesystemFindFilesTest.php @@ -179,7 +179,7 @@ protected function assertSameArray(array $expected, string $directory, string|fa $files = (new Filesystem(Hyde::getInstance()))->findFiles($directory, $matchExtension, $recursive); // Compare sorted arrays because some filesystems may return files in a different order. - $this->assertSame(collect($expected)->sort()->values()->all(), $files->sort()->values()->all()); + $this->assertSame(collect($expected)->sort()->values()->all(), $files->all()); } protected function tearDown(): void