|
13 | 13 | use OCA\GroupFolders\Folder\FolderDefinition; |
14 | 14 | use OCA\GroupFolders\Folder\FolderDefinitionWithPermissions; |
15 | 15 | use OCA\GroupFolders\Folder\FolderManager; |
| 16 | +use OCA\GroupFolders\Folder\FolderWithMappingsAndCache; |
16 | 17 | use OCA\GroupFolders\Mount\FolderStorageManager; |
17 | 18 | use OCA\GroupFolders\ResponseDefinitions; |
18 | 19 | use OCP\Constants; |
@@ -661,4 +662,37 @@ public function testCanManageACLCacheInvalidatedOnUserDeletion(): void { |
661 | 662 | $this->manager->deleteUser('bob'); |
662 | 663 | $this->assertFalse($this->manager->canManageACL($folderId, $user)); |
663 | 664 | } |
| 665 | + |
| 666 | + public function testGetAllFoldersWithSizeOrderedByGroups(): void { |
| 667 | + $this->config->expects($this->any()) |
| 668 | + ->method('getSystemValueInt') |
| 669 | + ->with('groupfolders.quota.default', FileInfo::SPACE_UNLIMITED) |
| 670 | + ->willReturn(FileInfo::SPACE_UNLIMITED); |
| 671 | + |
| 672 | + // Create folders with a different number of applicable groups each. |
| 673 | + $oneGroup = $this->manager->createFolder('one-group'); |
| 674 | + $threeGroups = $this->manager->createFolder('three-groups'); |
| 675 | + $twoGroups = $this->manager->createFolder('two-groups'); |
| 676 | + |
| 677 | + $this->manager->addApplicableGroup($oneGroup, 'g1'); |
| 678 | + |
| 679 | + $this->manager->addApplicableGroup($twoGroups, 'g1'); |
| 680 | + $this->manager->addApplicableGroup($twoGroups, 'g2'); |
| 681 | + |
| 682 | + $this->manager->addApplicableGroup($threeGroups, 'g1'); |
| 683 | + $this->manager->addApplicableGroup($threeGroups, 'g2'); |
| 684 | + $this->manager->addApplicableGroup($threeGroups, 'g3'); |
| 685 | + |
| 686 | + $ascending = array_map( |
| 687 | + fn (FolderWithMappingsAndCache $folder): string => $folder->mountPoint, |
| 688 | + array_values($this->manager->getAllFoldersWithSize(0, null, 'groups', 'ASC')), |
| 689 | + ); |
| 690 | + $this->assertEquals(['one-group', 'two-groups', 'three-groups'], $ascending); |
| 691 | + |
| 692 | + $descending = array_map( |
| 693 | + fn (FolderWithMappingsAndCache $folder): string => $folder->mountPoint, |
| 694 | + array_values($this->manager->getAllFoldersWithSize(0, null, 'groups', 'DESC')), |
| 695 | + ); |
| 696 | + $this->assertEquals(['three-groups', 'two-groups', 'one-group'], $descending); |
| 697 | + } |
664 | 698 | } |
0 commit comments