Skip to content

Commit

Permalink
Sort the values to normalize between filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 14, 2024
1 parent a4d4701 commit be1d051
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/framework/src/Foundation/Kernel/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion packages/framework/tests/Unit/FilesystemFindFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be1d051

Please sign in to comment.