summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-02-23 18:00:12 +0100
committerRobin Appelman <robin@icewind.nl>2024-02-26 18:46:35 +0100
commitd0ebe369061027e8026b93b5083dcaadc3a25412 (patch)
tree1668a8f57e14a6b878bf4db07748e42233ae752e
parent00c53c9e78ffca1985b4b22314af08da10a09826 (diff)
downloadnextcloud-server-d0ebe369061027e8026b93b5083dcaadc3a25412.tar.gz
nextcloud-server-d0ebe369061027e8026b93b5083dcaadc3a25412.zip
fix: remove old test-only methods
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_sharing/tests/UpdaterTest.php8
-rw-r--r--lib/private/Share/Share.php35
-rw-r--r--tests/lib/Share/Backend.php10
3 files changed, 13 insertions, 40 deletions
diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php
index fbdfad2f9cb..98e34a272e0 100644
--- a/apps/files_sharing/tests/UpdaterTest.php
+++ b/apps/files_sharing/tests/UpdaterTest.php
@@ -99,8 +99,8 @@ class UpdaterTest extends TestCase {
// check if user2 can see the shared folder
$this->assertTrue($view->file_exists($this->folder));
- $foldersShared = \OC\Share\Share::getItemsSharedWith('folder');
- $this->assertSame(1, count($foldersShared));
+ $foldersShared = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER);
+ $this->assertCount(1, $foldersShared);
$view->mkdir('localFolder');
$view->file_put_contents('localFolder/localFile.txt', 'local file');
@@ -116,8 +116,8 @@ class UpdaterTest extends TestCase {
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
// shared folder should be unshared
- $foldersShared = \OC\Share\Share::getItemsSharedWith('folder');
- $this->assertTrue(empty($foldersShared));
+ $foldersShared = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER);
+ $this->assertCount(0, $foldersShared);
// trashbin should contain the local file but not the mount point
$rootView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index 8322c141b1f..d94d389fc4d 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -94,41 +94,6 @@ class Share extends Constants {
}
/**
- * Get the items of item type shared with the current user
- *
- * @param string $itemType
- * @param int $format (optional) Format type must be defined by the backend
- * @param mixed $parameters (optional)
- * @param int $limit Number of items to return (optional) Returns all by default
- * @param boolean $includeCollections (optional)
- * @return mixed Return depends on format
- * @deprecated TESTS ONLY - this methods is only used by tests
- * called like this:
- * \OC\Share\Share::getItemsSharedWith('folder'); (apps/files_sharing/tests/UpdaterTest.php)
- */
- public static function getItemsSharedWith() {
- return self::getItems('folder', null, self::$shareTypeUserAndGroups, \OC_User::getUser());
- }
-
- /**
- * Get the items of item type shared with a user
- *
- * @param string $itemType
- * @param string $user id for which user we want the shares
- * @param int $format (optional) Format type must be defined by the backend
- * @param mixed $parameters (optional)
- * @param int $limit Number of items to return (optional) Returns all by default
- * @param boolean $includeCollections (optional)
- * @return mixed Return depends on format
- * @deprecated TESTS ONLY - this methods is only used by tests
- * called like this:
- * \OC\Share\Share::getItemsSharedWithUser('test', $shareWith); (tests/lib/Share/Backend.php)
- */
- public static function getItemsSharedWithUser($itemType, $user) {
- return self::getItems('test', null, self::$shareTypeUserAndGroups, $user);
- }
-
- /**
* Get the item of item type shared with a given user by source
*
* @param string $itemType
diff --git a/tests/lib/Share/Backend.php b/tests/lib/Share/Backend.php
index 18443a4e247..f383d804971 100644
--- a/tests/lib/Share/Backend.php
+++ b/tests/lib/Share/Backend.php
@@ -21,6 +21,10 @@
namespace Test\Share;
+use OC\Share20\Manager;
+use OCP\Server;
+use OCP\Share\IShare;
+
class Backend implements \OCP\Share_Backend {
public const FORMAT_SOURCE = 0;
public const FORMAT_TARGET = 1;
@@ -46,7 +50,11 @@ class Backend implements \OCP\Share_Backend {
}
- $shares = \OC\Share\Share::getItemsSharedWithUser('test', $shareWith);
+ $shareManager = Server::get(Manager::class);
+ $shares = array_merge(
+ $shareManager->getSharedWith($shareWith, IShare::TYPE_USER),
+ $shareManager->getSharedWith($shareWith, IShare::TYPE_GROUP),
+ );
$knownTargets = [];
foreach ($shares as $share) {