Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-08-12 14:31:29 +0300
committerJohn Molakvoæ <skjnldsv@protonmail.com>2021-10-19 12:31:08 +0300
commitef93d2ea1c089d65660591857e5f6a1608210d3c (patch)
tree23218257ea05fb449bb156172426fe1efb6c53b3 /apps/files_sharing
parent7345de78c582ffcb01c56e2a0c38788eb913d414 (diff)
update tests
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Hooks.php18
-rw-r--r--apps/files_sharing/tests/External/ManagerTest.php11
-rw-r--r--apps/files_sharing/tests/TestCase.php10
3 files changed, 20 insertions, 19 deletions
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index f28f6910abd..1c93d913eaf 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -27,26 +27,10 @@
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
-use OCP\EventDispatcher\IEventDispatcher;
-use Psr\Log\LoggerInterface;
class Hooks {
public static function deleteUser($params) {
- $manager = new External\Manager(
- \OC::$server->getDatabaseConnection(),
- \OC\Files\Filesystem::getMountManager(),
- \OC\Files\Filesystem::getLoader(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getNotificationManager(),
- \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
- \OC::$server->getCloudFederationProviderManager(),
- \OC::$server->getCloudFederationFactory(),
- \OC::$server->getGroupManager(),
- \OC::$server->getUserManager(),
- $params['uid'],
- \OC::$server->query(IEventDispatcher::class),
- \OC::$server->get(LoggerInterface::class)
- );
+ $manager = \OC::$server->get(External\Manager::class);
$manager->removeUserShares($params['uid']);
}
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 335425b7a12..ab7c682c3a6 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -44,7 +44,9 @@ use OCP\Http\Client\IResponse;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IURLGenerator;
+use OCP\IUser;
use OCP\IUserManager;
+use OCP\IUserSession;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
use Test\Traits\UserTrait;
@@ -153,6 +155,13 @@ class ManagerTest extends TestCase {
}
private function createManagerForUser($userId) {
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn($userId);
+ $userSession = $this->createMock(IUserSession::class);
+ $userSession->method('getUser')
+ ->willReturn($user);
+
return $this->getMockBuilder(Manager::class)
->setConstructorArgs(
[
@@ -166,7 +175,7 @@ class ManagerTest extends TestCase {
$this->cloudFederationFactory,
$this->groupManager,
$this->userManager,
- $userId,
+ $userSession,
$this->eventDispatcher,
$this->logger,
]
diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php
index 54c8704df81..bb1e3125ab2 100644
--- a/apps/files_sharing/tests/TestCase.php
+++ b/apps/files_sharing/tests/TestCase.php
@@ -34,6 +34,9 @@ namespace OCA\Files_Sharing\Tests;
use OC\Files\Filesystem;
use OCA\Files_Sharing\AppInfo\Application;
+use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
+use OCA\Files_Sharing\MountProvider;
+use OCP\Files\Config\IMountProviderCollection;
use OCP\Share\IShare;
use Test\Traits\MountProviderTrait;
@@ -71,7 +74,12 @@ abstract class TestCase extends \Test\TestCase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
- new Application();
+ $app = new Application();
+ $app->registerMountProviders(
+ \OC::$server->get(IMountProviderCollection::class),
+ \OC::$server->get(MountProvider::class),
+ \OC::$server->get(ExternalMountProvider::class),
+ );
// reset backend
\OC_User::clearBackends();