diff options
author | Robin Appelman <robin@icewind.nl> | 2023-02-06 18:56:54 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2023-02-07 15:50:10 +0100 |
commit | 9f3dbb699a4e1e0fbfc55e1fb9bb070e26816e20 (patch) | |
tree | a502b5711981e53221cea6c2fbd216478a9085a8 | |
parent | e3bafcc7a813f6adb305c2e35057b925c278d4bd (diff) | |
download | nextcloud-server-9f3dbb699a4e1e0fbfc55e1fb9bb070e26816e20.tar.gz nextcloud-server-9f3dbb699a4e1e0fbfc55e1fb9bb070e26816e20.zip |
fix tests
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/Mount/MountPoint.php | 14 | ||||
-rw-r--r-- | lib/public/Files/Mount/IMountPoint.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/ViewTest.php | 3 |
3 files changed, 16 insertions, 5 deletions
diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 67601f016be..20e08120080 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -196,11 +196,15 @@ class MountPoint implements IMountPoint { } /** - * @return string + * @return string|null */ public function getStorageId() { if (!$this->storageId) { - $this->storageId = $this->getStorage()->getId(); + $storage = $this->getStorage(); + if (is_null($storage)) { + return null; + } + $this->storageId = $storage->getId(); if (strlen($this->storageId) > 64) { $this->storageId = md5($this->storageId); } @@ -213,7 +217,11 @@ class MountPoint implements IMountPoint { */ public function getNumericStorageId() { if (is_null($this->numericStorageId)) { - $this->numericStorageId = $this->getStorage()->getStorageCache()->getNumericId(); + $storage = $this->getStorage(); + if (is_null($storage)) { + return -1; + } + $this->numericStorageId = $storage->getStorageCache()->getNumericId(); } return $this->numericStorageId; } diff --git a/lib/public/Files/Mount/IMountPoint.php b/lib/public/Files/Mount/IMountPoint.php index b8e7ec9118f..1272550d737 100644 --- a/lib/public/Files/Mount/IMountPoint.php +++ b/lib/public/Files/Mount/IMountPoint.php @@ -55,7 +55,7 @@ interface IMountPoint { /** * Get the id of the storages * - * @return string + * @return string|null * @since 8.0.0 */ public function getStorageId(); @@ -63,7 +63,7 @@ interface IMountPoint { /** * Get the id of the storages * - * @return int + * @return int|null * @since 9.1.0 */ public function getNumericStorageId(); diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 2189e7c09f4..95d9a8e3051 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1590,6 +1590,9 @@ class ViewTest extends \Test\TestCase { ->setConstructorArgs([[]]) ->getMock(); $storage->method('getId')->willReturn('non-null-id'); + $storage->method('getStorageCache')->willReturnCallback(function () use ($storage) { + return new \OC\Files\Cache\Storage($storage); + }); $mounts[] = $this->getMockBuilder(TestMoveableMountPoint::class) ->setMethods(['moveMount']) |