]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix tests 36566/head
authorRobin Appelman <robin@icewind.nl>
Mon, 6 Feb 2023 17:56:54 +0000 (18:56 +0100)
committerRobin Appelman <robin@icewind.nl>
Tue, 7 Feb 2023 14:50:10 +0000 (15:50 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Mount/MountPoint.php
lib/public/Files/Mount/IMountPoint.php
tests/lib/Files/ViewTest.php

index 67601f016be7c5993754e54e88168a00f12923d6..20e081200805a6bbb42811f019d32e07d30c8dbd 100644 (file)
@@ -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;
        }
index b8e7ec9118f20a9d4acbad5db32826f5e0dadd9c..1272550d737798aa713b09092dfbb618d3870a0e 100644 (file)
@@ -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();
index 2189e7c09f4310b78945aeb12cbaf95fa6918413..95d9a8e3051eb1a2464d3fea3b86346bd390f3e6 100644 (file)
@@ -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'])