Skip to content

Commit 75fe4c9

Browse files
committed
test: adjust tests to new getById
Signed-off-by: Robin Appelman <[email protected]>
1 parent 8a5cc33 commit 75fe4c9

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

tests/lib/Files/Node/FolderTest.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use OC\Files\View;
3030
use OCP\Constants;
3131
use OCP\Files\Cache\ICacheEntry;
32+
use OCP\Files\Config\ICachedMountInfo;
3233
use OCP\Files\InvalidPathException;
3334
use OCP\Files\IRootFolder;
3435
use OCP\Files\Mount\IMountPoint;
@@ -538,8 +539,8 @@ public function testGetById(): void {
538539
->with('/bar/foo')
539540
->willReturn([]);
540541

541-
$manager->method('getMountsByMountProvider')
542-
->willReturn([$mount]);
542+
$manager->method('getMountFromMountInfo')
543+
->willReturn($mount);
543544

544545
$node = new Folder($root, $view, '/bar/foo');
545546
$result = $node->getById(1);
@@ -583,8 +584,8 @@ public function testGetByIdMountRoot(): void {
583584
->with(1)
584585
->willReturn($fileInfo);
585586

586-
$manager->method('getMountsByMountProvider')
587-
->willReturn([$mount]);
587+
$manager->method('getMountFromMountInfo')
588+
->willReturn($mount);
588589

589590
$node = new Folder($root, $view, '/bar');
590591
$result = $node->getById(1);
@@ -628,8 +629,8 @@ public function testGetByIdOutsideFolder(): void {
628629
->with(1)
629630
->willReturn($fileInfo);
630631

631-
$manager->method('getMountsByMountProvider')
632-
->willReturn([$mount]);
632+
$manager->method('getMountFromMountInfo')
633+
->willReturn($mount);
633634

634635
$node = new Folder($root, $view, '/bar/foo');
635636
$result = $node->getById(1);
@@ -668,14 +669,31 @@ public function testGetByIdMultipleStorages(): void {
668669
1,
669670
''
670671
),
672+
new CachedMountInfo(
673+
$this->user,
674+
1,
675+
0,
676+
'/bar/foo/asd/',
677+
'test',
678+
1,
679+
''
680+
),
671681
]);
672682

673683
$cache->method('get')
674684
->with(1)
675685
->willReturn($fileInfo);
676686

677-
$manager->method('getMountsByMountProvider')
678-
->willReturn([$mount1, $mount2]);
687+
$manager->method('getMountFromMountInfo')
688+
->willReturnCallback(function (ICachedMountInfo $mountInfo) use ($mount1, $mount2) {
689+
if ($mountInfo->getMountPoint() === $mount1->getMountPoint()) {
690+
return $mount1;
691+
}
692+
if ($mountInfo->getMountPoint() === $mount2->getMountPoint()) {
693+
return $mount2;
694+
}
695+
return null;
696+
});
679697

680698
$node = new Folder($root, $view, '/bar/foo');
681699
$result = $node->getById(1);

0 commit comments

Comments
 (0)