Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ public function __construct($webRoot, \OC\Config $config) {
return $manager;
});

$this->registerAlias(MountProviderCollection::class, IMountProviderCollection::class);

$this->registerService(IBus::class, function (ContainerInterface $c) {
$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
if ($busClass) {
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use OC\Files\View;
use OC\Installer;
use OC\Updater;
use OCA\Files_Sharing\MountProvider;
use OCP\Command\IBus;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\IRootFolder;
Expand Down Expand Up @@ -315,13 +316,13 @@ public static function tearDownAfterClass(): void {
$setupManager = Server::get(SetupManager::class);
$setupManager->tearDown();

/** @var MountProviderCollection $mountProviderCollection */
$mountProviderCollection = Server::get(MountProviderCollection::class);
$mountProviderCollection->clearProviders();

/** @var IConfig $config */
$config = Server::get(IConfig::class);
$mountProviderCollection->registerProvider(new CacheMountProvider($config));
$mountProviderCollection->registerProvider(Server::get(MountProvider::class));
$mountProviderCollection->registerHomeProvider(new LocalHomeMountProvider());
$objectStoreConfig = Server::get(PrimaryObjectStoreConfig::class);
$mountProviderCollection->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
Expand Down
48 changes: 48 additions & 0 deletions tests/lib/TestCaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace Test;

use OCP\Constants;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Server;
use OCP\Share\IManager;
use OCP\Share\IShare;
use Test\Traits\UserTrait;

#[\PHPUnit\Framework\Attributes\Group('DB')]
class TestCaseTest extends TestCase {
use UserTrait;

// This test cannot fail if this suite is run standalone.
// It will only fail if the mount provider collection wasn't correctly reset after a different test suite was executed before this one.
public function testMountProviderCollectionReset(): void {
$owner = $this->createUser('owner', 'password');
$receiver = $this->createUser('receiver', 'password');

$ownerUserFolder = Server::get(IRootFolder::class)->getUserFolder($owner->getUID());
$ownerNode = $ownerUserFolder->newFolder('foo');
$this->assertInstanceOf(Folder::class, $ownerNode);

$manager = Server::get(IManager::class);
$manager->createShare(
$manager->newShare()
->setShareType(IShare::TYPE_USER)
->setShareOwner($owner->getUID())
->setSharedBy($owner->getUID())
->setSharedWith($receiver->getUID())
->setNode($ownerNode)
->setPermissions(Constants::PERMISSION_ALL)
);

$receiverUserFolder = Server::get(IRootFolder::class)->getUserFolder($receiver->getUID());
$receiverNode = $receiverUserFolder->get($ownerNode->getName());
$this->assertInstanceOf(Folder::class, $receiverNode);
}
}
Loading