Skip to content

Commit 4b49ad1

Browse files
DeepDiver1975claude
andcommitted
test(trashbin): fix version-sort expectation and add empty-result case
The first assertion in testGetVersionsFromTrash() expected ['1', '10', '2'], but sort() uses SORT_REGULAR and sorts the numeric version strings numerically -> ['1', '2', '10'], so the test failed. Correct the expected order and add a case asserting an empty result for a file that has no stored versions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
1 parent f30144b commit 4b49ad1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/files_trashbin/tests/StorageTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,10 +956,11 @@ public function testGetVersionsFromTrash() {
956956
$scannedVersions->setAccessible(true);
957957

958958
// timestamped lookup in the versions root
959+
// (sort() uses SORT_REGULAR, so the numeric version strings sort numerically)
959960
$scannedVersions->setValue(null, false);
960961
$versions = $method->invoke(null, 'test.txt', $timestamp, $this->user);
961962
\sort($versions);
962-
$this->assertEquals(['1', '10', '2'], $versions);
963+
$this->assertEquals(['1', '2', '10'], $versions);
963964

964965
// non-timestamped lookup inside a sub-folder (issue #31682 regression:
965966
// the previous whole-cache name search found these, the directory
@@ -968,6 +969,11 @@ public function testGetVersionsFromTrash() {
968969
$versions = $method->invoke(null, 'nested.txt', null, $this->user, 'folder');
969970
\sort($versions);
970971
$this->assertEquals(['5', '6'], $versions);
972+
973+
// a file with no stored versions yields an empty result
974+
$scannedVersions->setValue(null, false);
975+
$versions = $method->invoke(null, 'no-such-file.txt', $timestamp, $this->user);
976+
$this->assertEquals([], $versions);
971977
}
972978

973979
private function markTestSkippedIfStorageHasOwnVersioning() {

0 commit comments

Comments
 (0)